0
如何創建比例表並在表的第一列中包含變量名?如何在R中創建比例表
這裏是我的代碼:
time <- c("Morning", "Evening" ,"Morning", "Morning", "Afternoon", "Evening", "Afternoon")
dollar <- c("1-5", "6-10", "11-15", "1-5", "1-5", "6-10", "6-10")
with_kids <- c("no", "yes", "yes", "no", "no", "yes", "yes")
cluster <- c(1,1,2,3,2,2,3)
dat <- data.frame(time, dollar, with_kids, cluster)
myList <- lapply(dat[head(names(dat), -1)], table, dat$cluster)
myList_Prop <- lapply(myList, prop.table, margin=2)
原題:Table of categorical variables by a grouping variable in R
嘗試'Reduce(「rbind」,myList_Prop)' – CPak
錯誤已修復。 – Ketty
你想獲得打印在屏幕上的輸出還是你想在LaTex中使用它? – simone