I have 2 data frames which look like this:
y = data.frame(ID= c(1, 1, 2, 2, 3, 3), year = c("2007", "2008", "2007", "2008", "2007", "2008"), aprank = c(3, 4, 1, 2, 5, 8))
z = data.frame(ID = c(1, 1, 1, 1 2, 2, 2, 2, 3, 3, 3, 3), year = c("2006", "2007", "2008", "2009", "2006", "2007", 2008, 2009, 2006, 2007, 2008, 2009), freq = c(500, 600, 800, 900, 200, 150, 300, 500, 100, 150, 300, 301))
and I'm expecting an outcome something like this:
t = data.frame(ID = c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3), year = c("2006", "2007", "2008", "2009", "2006", "2007", 2008, 2009, 2006, 2007, 2008, 2009), aprank = c(NA, 3, 4, NA, NA, 1,2, NA, NA, 5, 8, NA), freq = c(500, 600, 800, 900, 200, 150, 300, 500, 100, 150, 300, 301))
How can I do that? Any help would be appreciated