有关如何将多个变量的ranef((输出组合在一起以导出到excel的任何帮助
您可以使用XLConnect
包将lme4
包的ranef
输出保存到Excel文件中。请看下面的例子:
#simulation of data
library(lme4)
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
rr1 <- ranef(fm1, condVar = TRUE)
df <- as.data.frame(rr1$Subject)
#writing to xls file
library(XLConnect)
wb <- loadWorkbook("ranef_res.xlsx", create = TRUE)
createSheet(wb, "ranef")
writeWorksheet(wb, df, "ranef")
saveWorkbook(wb)