I have a list of 3 data.frames (X, Y, Z). Using BASE R, I was wondering how I could cbind similarly named variables across these data.frames and store them as a list?
For the example below, I want all variable AAs across the the 3 data.frames, all variable BBs across the the 3 data.frames, and all variable CCs the the 3 data.frames be separately cbinded and stored as a list?
Note: names could be anything, and the number of variables could be any number. A function(al) solution is highly appreciated.
r <- list(
X = data.frame(
AA = c(1,1,1,1,3,2),
BB = c(1,1,1,2,2,2),
CC = c(2,2,3,1,2,1)),
Y = data.frame(
AA = c(1,1,1,1,3,2),
BB = c(1,1,1,2,2,2),
CC = c(2,2,3,1,2,1)),
Z = data.frame(
AA = c(1,1,1,1,3,2),
BB = c(1,1,1,2,2,2),
CC = c(2,2,3,1,2,1)))