Thank you so much for your reactivity, pivot_wider does wonders !
I bumped into another problem now though:
One of my tables is stored as follow:
2000 2001 2002
FRA GDP 990 1000 1010
FRA Expenditure 100 110 120
I used pivot_longer to change it to what I will call an "annoying table":
FRA GDP 2000 990
FRA Expenditure 2000 100
FRA GDP 2001 1000
FRA Expenditure 2001 110
This table looks exactly the way the other looked like initially.
And whereas pivot_wider did wonders with these other tables, I does not work with the annoying one.
It tried pivot_wider to get this annoying table to:
GDP Expenditure
FRA 2000 990 100
FRA 2001 1000 110
instead, I get the error
Column 2 must be named. Use .name_repair to specify repair
My script is the following - it uses data downloaded from the World Development Indicators (WDI):
WDI3<- pivot_longer(WDI2,
cols = c("1999","2000","2001","2002","2003","2004","2005","2006","2007",
"2008","2009","2010","2011","2012","2013","2014","2015"),
names_to = "Year",
values_to = "Value")
WDI_filtered <-subset(WDI3,select = c("Series.Name","Country.Name",
"Country.Code","Year","Value"))
head(WDI_filtered)
class(UNESCO)
class(WDI_filtered)
WDI_wide <- pivot_wider(WDI_filtered,names_from = Series.Name,
values_from = Value,values_fill = NULL,names_repair = Series)
The last step (creating WDI_wide) yields the error
any clue ?