Home > OS >  CREATE A TIME SERIES PLOT in r with ggplot
CREATE A TIME SERIES PLOT in r with ggplot

Time:08-10

I have problems with coding of BIG DATA.

view(data)

Year Month Deaths
1998 1 200
1998 2 40
1998 3 185
1998 4 402
1998 5 20
1998 6 48
1998 7 290
1998 8 15
1998 9 252
1998 10 409
1998 11 233
1998 12 122

My data goes until 2014. I would like to create a time series. In the x-Axis only some years are available in 5 year step. In the y axis the deaths of all month during the 2000 years are shown. I don't know how can I code that?

CodePudding user response:

I am not sure if it is right because I didn't have any data. I have this from a programming book

data$date = as.Date(paste(data$Year, data$Month,1), format = "%Y %m %d")

ggplot(data,
       aes(
         x = date,
         y = Deaths,
        ))  
  geom_line()  
  ggtitle("Time series")  
  xlab("Year")  
  ylab("Deaths")

  •  Tags:  
  • r
  • Related