I want to slice a few rows and add the data back into the dataset as another variable. so my task goes like this... converting
location   year   value
aus       1990    1
aus       1991    2
aus       1992    2
usa       1990    1
usa       1991    3
usa       1992    2
uk        1990    3
uk        1991    2
uk        1992    2   
...     
into something like this
year   value_aus   value_usa   value_uk
1990      1            1          3
1991      2            3          2
1992      2            2          2
.
.
.
my data have 56 years for 36 different countries.
I tried as follows..
nations<-factor(data$LOCATION)
nationlist<-nations[!duplicated(nations)]
data_w<-data.frame(year=data$TIME[data$LOCATION==nationlist[1]])
for(loc in c(as.character(nationlist))){
  data_w<-data.frame(data_w[,], loc = data$Value[data$LOCATION==loc], check.rows=TRUE)
  }
but this didn't work and spits out "arguments imply differing number of rows: 56, 54" as some of the countries have different number of observations(years in this case) i guess.
Any helps would be greatly appreciated.
Jinseok
 
    