I find it difficult to put what I want words to, so I will try to follow an example to explain this. Let's say I repeated the experiment twice and had two tables:
[df1] [df2]
X Y X Y
2 3 4 1
5 2 2 4
These tables are stored in the list (if the list can contain more than two elements, if necessary), and I want to create an average value for each cell in the tables in the list (or for the generalized version, use any function that I select for the cells, i.e. . mad, sd, etc.)
[df1] [df2] [dfMeans]
X Y X Y X Y
2 3 4 1 mean(2,4) mean(3,1)
5 2 2 4 mean(5,2) mean(2,4)
I have a code solution for my problem, but since this is in R, this is most likely a cleaner way to do something:
df1 <- data.frame(X=c(2,3,4),Y=c(3,2,1))
df2 <- data.frame(X=c(5,1,3),Y=c(4,1,4))
df3 <- data.frame(X=c(2,7,4),Y=c(1,7,6))
dfList <- list(df1,df2,df3)
dfMeans <- data.frame(MeanX=c(NA,NA,NA),MeanY=c(NA,NA,NA))
for (rowIndex in 1:nrow(df1)) {
for (colIndex in 1:ncol(df1)) {
valuesAtCell <- c()
for (tableIndex in 1:length(dfList)) {
valuesAtCell <- c(valuesAtCell, dfList[[tableIndex]][rowIndex,colIndex])
}
dfMeans[rowIndex, colIndex] <- mean(valuesAtCell)
}
}
print(dfMeans)