I have the following data.frame and I would like to create another data.frame (say M) that would store mean of A1 from M1,M2,M3, mean of B1, from M1,M2,M3 and likewise for C1.
library(tidyverse)
set.seed(123)
M1 <- data.frame(Date = seq(as.Date("2001-01-01"), to = as.Date("2005-12-31"), by = "month"),
A1 = runif(60,1,5),
B1 = runif(60,1,5),
C1 = runif(60,1,5))
M2 <- data.frame(Date = seq(as.Date("2001-01-01"), to = as.Date("2005-12-31"), by = "month"),
A1 = runif(60,1,5),
B1 = runif(60,1,5),
C1 = runif(60,1,5))
M3 <- data.frame(Date = seq(as.Date("2001-01-01"), to = as.Date("2005-12-31"), by = "month"),
A1 = runif(60,1,5),
B1 = runif(60,1,5),
C1 = runif(60,1,5))
Desired output
The output would be a data.frame (M) with variables of A (mean of A1 from M1,M2,M3), B (mean of B1 from M1,M2,M3), and C (mean of C1 from M1,M2,M3).