[R] merging two lists but get indexes

Teng Sun ewisdom at gmail.com
Sun Jan 14 14:37:10 CET 2007


Suppose I have two columns of entries, how can I get the union of the
two columns? Please note: I input my columns through excel. These
entries have text format in excel. Also, out of curiosity, how can I
find out the data type of a data frame ?


> a <- read.csv("book1.csv")
> a
      n1     n2
1  apple   soda
2 orange  apple
3   soda  green
4    red yellow
5  white   blue
6         white

> union(a$n1,a$n2)
[1] 2 3 5 4 6 1

I want the actual names instead of the indexes.



More information about the R-help mailing list