Philippe
Philippe

Reputation: 11

Graphics with dataframe

I have a table with export of every EU country:

country 2001  2002  2003  .....
france  12023 54554 251515 ....
.....

I would like to do a plot with the value of every years for 4 country (e.g. Germany, Italy, France, Netherlands). It's a dataframe I have tried with those commands:

y<-ts(EXEU)
y
plot(y[5,],type="o")

But when I use ts I lose all the name of the countries and I have on the x-axis frequency not every years. It's possible to do the same without use ts().

Upvotes: 0

Views: 76

Answers (1)

Nikos
Nikos

Reputation: 3297

Try this:

library(reshape2)
library(ggplot2)

#EXEU is your dataframe
EXEU<-melt(EXEU,id='country',variable.name='YEAR',value.name='VALUE')
ggplot(EXEU,aes(YEAR,VALUE,group=country, color=country))+geom_line()

Picture example

Upvotes: 1

Related Questions