有关如何将多个变量的ranef()的输出结合在一起以导出到excel的任何帮助
答案 0 :(得分:0)
您可以使用XLConnect
包将ranef
包的lme4
的输出保存到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)