The data that I have on R is of the following type:
Data = data.frame(Individual = c(1,1,2,2), Year=c(2000,2001, 2000,2001), Variable=c('x','x','y','y'), Value=c(1,2,3,4))
Individual Year Variable Value
1 1 2000 x 1
2 1 2001 x 2
3 1 2000 y 3
4 1 2001 y 4
I have data by individuals, by year, for 2 variables, x and y. What I wish is to reshape the data wide. In other words, I would like to, instead of having 4 observations (2 per person), have just two observations, but instead of concatenating x and y, have them as separate columns.
Ideally, the data would look like:
Individual Year x y
1 1 2000 1 3
2 1 2001 2 4
I am new to R, and am making use of the wonderful dplyr() package. I have come across the sep() functions, but that does not seem to be exactly what I am looking for. Any help on this is much appreciated.