[R] : record which entry in one file doesn't appear in a different file

Patrizio Frederic frederic.patrizio at gmail.com
Wed Feb 25 17:41:15 CET 2009


hey Laura,
I hope this help

f1 = c("a","b","c")
f2 = c("b","a","c","d")
match(f2,f1)
f3 = match(f2,f1,0)
?match
cbind(f2,f3)
cbind(f2,f3>0)
f4 = ifelse(f3>0,"yes","no")
cbind(f2,f4)
data.frame(f2,f4)

Patrizio

2009/2/25 Laura Rodriguez Murillo <laura.lmurillo at gmail.com>:
> Hi dear list,
>
> If anybody could help me, it would be great!
>
> I have two files:
> File 1 is a list (one column and around 100000 rows)
> File 2 is a list with all the names from file one and a few more (one
> column and more than 100000 rows)
>
> What I want is to add a column in file 2 that says which name appeared
> in file 1 and which doesn't (yes and no would work as a code)
> It's very important to keep the order of the names in file 2.
>
> Thank you!
>
> Laura
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list