I have a 3 ways frequency table, I want to combine them into a list, normally I write listOfTable <- list(table[,,1],table[,,2],table[,,3],table[,,4],table[,,5])
, sometimes my table is really long, there is any way I can apply lapply
to combine as a list without doing manually.
df <- data.frame(ID = c(rep(c("A","B","C"),5)),
N = c(rep(c("1","2","3"),5)),
M = c(rep(1,3),rep(2,3),rep(3,3),rep(4,3),rep(5,3)))
applyAlist <- table(df$ID,df$N,df$M)
listOfTable <- list(applyAlist[,,1],applyAlist[,,2],applyAlist[,,3],applyAlist[,,4],applyAlist[,,5])