Merging
fileUrl1 <- "https://dl.dropboxusercontent.com/u/7710864/data/reviews-apr29.csv"
fileUrl2 <- "https://dl.dropboxusercontent.com/u/7710864/data/solutions-apr29.csv"
download.file(fileUrl1,destfile="./data/reviews.csv",method="curl")
download.file(fileUrl2,destfile="./data/solutions.csv",method="curl")
reviews <- read.csv("./data/reviews.csv"); solutions <- read.csv("./data/solutions.csv")
head(reviews,2)
head(solutions,2)names(reviews)
names(solutions)> data = merge(reviews, solutions, by.x="solution_id", by.y="id", all=TRUE)> head(reviews, n=3)
id solution_id reviewer_id start stop time_left accept
1 1 3 27 1304095698 1304095758 1754 1
2 2 4 22 1304095188 1304095206 2306 1
3 3 5 28 1304095276 1304095320 2192 1
> head(solutions, n=3)
id problem_id subject_id start stop time_left answer
1 1 156 29 1304095119 1304095169 2343 B
2 2 269 25 1304095119 1304095183 2329 C
3 3 34 22 1304095127 1304095146 2366 C
> head(data, n=3)
solution_id id reviewer_id start.x stop.x time_left.x accept problem_id subject_id start.y
1 1 4 26 1304095267 1304095423 2089 1 156 29 1304095119
2 2 6 29 1304095471 1304095513 1999 1 269 25 1304095119
3 3 1 27 1304095698 1304095758 1754 1 34 22 1304095127
... and other columnsUsing join from plyr package
Merging multiple data frames
Last updated