r-beginner here,
Is there a way to convert a table that I have:
> 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")
so that the parameters from df$series become column names, filled with values from df$Value, while Country and Year stay fixed to look something like this:
Country Year GovernmentExpenditure Population LiteracyRate [otherparams]
Afghanistan 2000 10% 21979923 60%
Australia 2010 15% 21979923 90%
etc.
I tried dcast() but it didn't work the way I wanted to.
Alternatively, is there a way to download it in the necessary format straight away from the world bank data?
Thank you!