df1 -- dataframe with column date and several other columns. #rows >40k Several of the dates are repeated. df2 -- dataframe with two columns date and index. #rows ~130 This is really a map from date to index.
I would like to create a column called index in df1 which has the corresponding index from df2. The following works: index <- NULL for(wk in df1$week){ index <- c(index,df2$index[df2$week==wk]) } and then add index to df1. Can you please suggest a better way of doing this? I didn't think merge was suitable for this...is it? THANKS. ______________________________________________ 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.