Hi all, probably really simple to solve, but having no background in programming I haven't been able to figure this out: I have two dataframes like
df1 <- data.frame(names1=c('aa','ab', 'ac', 'ad'), var1=c(1,5,7,12)) df2 <- data.frame(names2=c('aa', 'ab', 'ac', 'ad', 'ae'), var2=c(3,6,9,12,15)) Now I want merge var1 to df2 by matching the dataframes by the 'names' columns, i.e. something like df3 <- merge (df2, df1, by.x='names2', by.y='names1', all.x=T) However, the original dataframes have quite a lot of columns and I thought that I should be able to address the var1 column by something like df1$var[[df2$name2]]. Could somebody please enlighten me and/or maybe suggest a short tutorial for the extraction operator? Thanks! Best, Kai [[alternative HTML version deleted]] ______________________________________________ R-help@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.