Vote count:
0
I have the following data set but am a newbie to the reshape2 functions:
df<-data.frame(Site=c("A", "A", "A", "B", "B", "C"),
PolygonArea=c(0.6, 0.3, 0.1, 0.7, 0.3, 1.0),
OriginYear=c(1900, 1910, 1905, 1950, 1975, 2000))
I want to turn df
into a dataframe with this structure:
df2<-data.frame(Site=c("A", "B", "C"),
PolygonArea1=c(0.6,0.7,1.0),
OriginYear1=c(1900, 1950,2000),
PolygonArea2 = c(0.3, 0.3, NA),
OriginYear2 = c(1910, 1975, NA),
PolygonArea3 = c(0.1, NA, NA),
OriginYear3 = c(1905, NA, NA))
I've tried without success to use the reshape2 package as my example has 'NA' cells as well as no aggregate function. Also, the column headers change names (i.e., the '1', '2', '3', etc.).
How do I do this?
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire