I have a dataset of countries health expenditure and life expectancy and wish to plot these visually.
I currently have the code:
dd = data.frame(Series_Name = "Health expenditure per capita (current US$) Australia",
Year = c(2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014),
Value = c(1665.200,1883.316,2370.881,2933.229,3214.031,3421.908,4077.852,4410.438,4256.641,5324.517,6368.424,6543.524,6258.467,6031.107))
Which I am then plotting with:
require(ggplot2)
##The values Year, Value, School_ID are
##inherited by the geoms
ggplot(dd, aes(Year, Value,colour=Series_Name)) +
geom_line() +
geom_point()
This displays the graph how I would like, although the issue is that I would to be able to specify which series of data should be placed within the value variable to avoid inputting it manually, the year does not need to be changed and can stay how it is.
The data has been read in from a csv file and saved to the variable 'statistics'. The data looks like this:
Series Name 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
Health expenditure per capita (current US$) Australia 1665.200 1883.316 2370.881 2933.229 3214.031 3421.908 4077.852 4410.438 4256.641 5324.517 6368.424 6543.524 6258.467 6031.107
If I wished to change data from Australia to Japan, how would I go about doing so, the Series name is set out the same with the exception of the country name.
Thanks for your help!
EDIT: Thought it may beneficial to add an image of the data layout.
The statistics.csv file - https://ufile.io/ocynw


tidyr::gather(df, key = year, value = expenditure, -Series Name)to reshape your data