if I have three time-series tables like:
df1 <- read.table(text = " Date V1 V2
2000-01-07 5 1
2000-01-08 1 4
2000-01-09 4 3
2000-01-10 0 0",
header = TRUE, stringsAsFactors = FALSE)
df2 <- read.table(text = " Date V1 V2
2000-01-01 1 1
2000-01-02 0 0
2000-01-03 4 6
2000-01-04 6 5
2000-01-05 3 0
2000-01-06 3 0
2000-01-07 7 4
2000-01-08 9 0
2000-01-09 0 0
2000-01-10 0 0",
header = TRUE, stringsAsFactors = FALSE)
df3 <- read.table(text = " Date V1 V2
2000-01-01 4 3
2000-01-02 4 0
2000-01-03 6 1
2000-01-04 7 5",
header = TRUE, stringsAsFactors = FALSE)
how could I create a table df4 which contains the oldest dates among the tables. then it organizes the seconds column of each table and finally the thirds columns of each table. Note that if the date doesn't exist.. if fills columns with NA.
df4 <- read.table(text = " Date df1_V1 df2_V1 df3_V1 df1_V2 df2_V2 df3_V2
2000-01-01 NA 1 4 NA 1 3
2000-01-02 NA 0 4 NA 0 0
2000-01-03 NA 4 6 NA 6 1
2000-01-04 NA 6 7 NA 5 5
2000-01-05 NA 3 NA NA 0 NA
2000-01-06 NA 3 NA NA 0 NA
2000-01-07 5 7 NA 1 4 NA
2000-01-08 1 9 NA 4 0 NA
2000-01-09 4 0 NA 3 0 NA
2000-01-10 0 0 NA 0 0 NA",
header = TRUE, stringsAsFactors = FALSE)