Sample data, a list of three identically-structured frames:
frames <- list(
frame1 = data.frame(x=1:3, y=4:6, z=7:9),
frame2 = data.frame(x=11:13, y=14:16, z=17:19),
frame3 = data.frame(x=21:23, y=24:26, z=27:29))
If instead you have three individual (not list of) frames, create the list with
frames <- list(Df1, Df2, Df3)
Transposing in a fashion:
newframes <- lapply(seq_len(ncol(frames[[1]])), function(i) {
as.data.frame(lapply(frames, `[[`, i))
})
names(newframes) <- names(frames[[1]])
newframes
# $x
# frame1 frame2 frame3
# 1 1 11 21
# 2 2 12 22
# 3 3 13 23
# $y
# frame1 frame2 frame3
# 1 4 14 24
# 2 5 15 25
# 3 6 16 26
# $z
# frame1 frame2 frame3
# 1 7 17 27
# 2 8 18 28
# 3 9 19 29
Writing to files:
for (nm in names(newframes)) write.csv(newframes[[nm]], paste0(nm, ".csv"))
This implementation makes the column names the name of the original frame, which is less ambiguous (in my opinion) than having them all the same column name x,x,x, y,y,y, etc). If you really need that though (and don't care that R will complain about it if you try to do follow-on work with it), then before writing it,
newframes <- Map(function(nm, x) `colnames<-`(x, rep(nm, ncol(x))),
names(newframes), newframes)
newframes
# $x
# x x x
# 1 1 11 21
# 2 2 12 22
# 3 3 13 23
# $y
# y y y
# 1 4 14 24
# 2 5 15 25
# 3 6 16 26
# $z
# z z z
# 1 7 17 27
# 2 8 18 28
# 3 9 19 29