[R] Column mapping

Stefan Grosse singularitaet at gmx.net
Wed Jul 28 08:06:47 CEST 2010


Am 28.07.2010 07:36, schrieb jd6688:
> 
> DF1
> name	OTHER	
> ABC	 O
> KKK	 O
> QQQ	 O
> DDD	 O
> PPP	 O
> 
> DF2
> name
> ABC
> KKK
> DDD
> 
> If the names in df1 mapped the names in df2, then add the mapped name to df1
> as a separate column, for instance "mappedColumn"

What do you mean by "mapped":
(1) how often a name in df1 is present or
(2) whether a name of DF1 is existing in DF2?

for (1) you could use DF1$existsinDF2<-DF1$name%in%DF2$name
for (2) use either aggregate or table (type ?aggregate or ?table at
command prompt for help.

Stefan



More information about the R-help mailing list