dfa <- data.frame(numid = c(1,2), numt = c(3,5), date = c("2012-03-21 12:32:11", "2011-11-03 04:32:11"), session = c("sessionA", "sessionB"))
dfb <- data.frame(numid = c(1,1,2), nums = c(402,321,34), date = c("2012-03-21 12:52:11","2012-03-21 12:41:32","2011-11-04 04:32:11"), session = c("sessionA", "sessionA", "sessionB"))
I would like to merge both data frame using the columns numid and session. However the fine data frame I would like to have the format as a melt option of the dfb where the numid is the same as of dfa and have the same value also in session column add the date of dfa. Example output:
dff <- data.frame(numid = c(1,1,2), date_dfa = c("2012-03-21 12:32:11", "2012-03-21 12:32:11", "2011-11-03 04:32:11"), nums = c(402,321,34), date = c("2012-03-21 12:52:11","2012-03-21 12:41:32","2011-11-04 04:32:11"), session = c("sessionA", "sessionA", "sessionB"))