r-beginner,
有没有办法转换我拥有的表:
> dput(head(ed, 5))
structure(list(series = c("Government expenditure on education, total (% of GDP)",
"Government expenditure on education, total (% of GDP)", "Government expenditure on education, total (% of GDP)",
"Government expenditure on education, total (% of GDP)", "Government expenditure on education, total (% of GDP)"
), country = c("Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",
"Afghanistan"), year = c("2000", "2001", "2002", "2003", "2004"
), Value = c(NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_)), .Names = c("series", "country", "year", "Value"
), row.names = c(NA, 5L), class = "data.frame")
以便来自df $ series的参数成为列名,用df $ Value填充值,而Country和Year保持固定看起来像这样:
Country Year GovernmentExpenditure Population LiteracyRate [otherparams]
Afghanistan 2000 10% 21979923 60%
Australia 2010 15% 21979923 90%
等
我尝试了dcast(),但它没有按照我想要的方式工作。
或者,有没有办法直接从世界银行数据中以必要的格式下载它?
谢谢!