I have two data frames, “data” and “ratings”, and you want to combine them in the “id” column:
data = data.frame(id = c(1,2,3,4,5), state = c("KS","MN","AL","FL","CA")) scores = data.frame(id = c(1,1,1,2,2,3,3,3), score = c(66,75,78,86,85,76,75,90)) merge(data, scores, by = "id") semi_join(data, scores, by = "id")
In the data “points” there is an “id” with several observations, where each match receives a row after combining. See ?merge :
If there is more than one match, all possible matches are entered one line at a time.
However, I want to save only the row corresponding to the first match from the scores table.
A semi-join would be nice, but I can't select a grade from the right table.
Any suggestions?