I have the following example data.frame which contains multiple variables (i.e., A,B,C).
set.seed(123)
D1 <- data.frame(Date = seq(as.Date("2001-01-01"), to= as.Date("2001-01-10"), by="day"),
A = runif(10,1,5),
B = runif(10,3,6),
C = runif(10,2,5))
D2 <- data.frame(Date = seq(as.Date("2001-01-01"), to= as.Date("2001-01-10"), by="day"),
A = runif(10,1,5),
B = runif(10,3,6),
C = runif(10,2,5))
D3 <- data.frame(Date = seq(as.Date("2001-01-01"), to= as.Date("2001-01-10"), by="day"),
A = runif(10,1,5),
B = runif(10,3,6),
C = runif(10,2,5))
Target
I want to grab each variables from all the data.frame and save it as a new data.frame with the name set as Variable and column names set as data.frame+variable like below
A <- data.frame(Date, D1A,D2A,D3A)
B <- data.frame(Date,D1B,D2B,D3B)
C <- data.frame(Date,D1C,D2C,D3C)
I would appreciate any help here.