How do I combine data into time series

Hello. I would like to ask how do I combine dataframes into time series.

For broader view, let me explain.

I have data for instance years 2006, 2007, 2008, 2009 and so on, but these are the different dataframes for each specific year. How do I combine these dataframes into one timeseries in R?

Thank you very much!
Kayo :slight_smile:

If the data frames have the same columns, you can use the rbind() function. Here is a simple example with invented data.

DF1 <- data.frame(Year = 2006, Month = 1:3, Value = rnorm(3))
DF2 <- data.frame(Year = 2007, Month = 1:3, Value = rnorm(3))
DF3 <- data.frame(Year = 2008, Month = 1:3, Value = rnorm(3))
AllDat <- rbind(DF1, DF2, DF3)
AllDat
  Year Month       Value
1 2006     1 -1.16610879
2 2006     2  1.26152712
3 2006     3  1.36811388
4 2007     1 -1.08850394
5 2007     2  0.74272501
6 2007     3 -0.92870791
7 2008     1  0.01184767
8 2008     2 -0.51484887
9 2008     3 -0.96681491

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.