[R] match and %in%

Luis Ridao Cruz Luisr at frs.fo
Thu Nov 10 12:33:33 CET 2005


R-help,

I have two data frames with a commom column (but with different size)
What I want is to get a column (say df1$mycolumn ) according to the
matches of common columns in both data frames.

I have tried this but it is not working:

transform(fb, breidd = ifelse (match (as.character(df1$puntar),
as.character(df2$puntar) )
, df2$breidd, "no" ) ) )

transform(fb, breidd = ifelse(as.character(df1$puntar) %in%
as.character(df2$puntar)
, df2$breidd, "no" ) ) )


Thank you in advance




More information about the R-help mailing list