I'm trying to make some barplots with data from the IMF. I tried to read the xls file with read.table():
base <- read.table("http://www.imf.org/external/pubs/ft/weo/2017/02/weodata/WEOOct2017all.xls", header=TRUE, sep="\t", fill=TRUE)
However, the data is saved as a list:
typeof(base)
[1] "list"
And I don't know how to extract the data to make a barplot. For example, I want to graph the variable "NGDP_RPCH", for the country "ARG" and the years 2010-2019 (columns 40-49 in the excel).
I tried this, but it didn't work:
graph <- base[which((base[2]=="ARG")&(base[3]=='NGDP_RPCH')),40:49]
graph
[1] X2010 X2011 X2012 X2013 X2014 X2015 X2016 X2017 X2018 X2019
<0 rows> (or 0-length row.names)
I would like to know how to save the data as a data frame, or how to extract a vector of data from the list, so I could run:
barplot(graph).