Dear users,
it is not such an statistical question but how to export results
I fit several *lme* model s and I know how can I export the data to excel,
this way:
lme1 <- lme(Mean ~ x*y, data = Data, random = ~ 1|factor(ID))
anova(lme1)->resultslme1
And to export to excel since keep the data in ordered in rows/columns
write.xlsx( resultslme1 ,"C:/Users/Desktop/resultslme1.xlsx")
What I want to do is to export output from several lme at the same time,
and adding the name/reference of the model. Something like this
lme1
numDF denDF F.value p.value
(Intercept) 1 78 653,6152 0
x 2 78 0,822612 0,443057
y 2 39 0,479357 0,622781
x:y 4 78 2,593825 0,042787
lme2
numDF denDF F.value p.value
(Intercept) 1 78 653,6152 0
x 2 78 0,822612 0,443057
y 2 39 0,479357 0,622781
x:y 4 78 2,593825 0,042787
I tried with merge, abind, paste,... but I did not find the solution
Thanks in advance
Mario Garrido Escudero, PhD
Dr. Hadas Hawlena Lab
Mitrani Department of Desert Ecology
Jacob Blaustein Institutes for Desert Research
Ben-Gurion University of the Negev
Midreshet Ben-Gurion 84990 ISRAEL
gaiarrido at gmail.com; gaadio at post.bgu.ac.il
phone: (+972) 08-659-6854
[[alternative HTML version deleted]]
Dear Mario,
Since anova( ) results are basically data.frames, a simple way could
be to add a column to identify the model, then row-bind the results.
Something like (using examples in the lme man page)
# First model
fm1 <- lme(distance ~ age, data = Orthodont)
anova( fm1 ) -> r1
r1$Md <- 1
# Second model
fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
anova( fm2 ) -> r2
r2$Md <- 2
# Bind results
r <- rbind( r1, r2 )
# Export
write.xlsx( r, "your_file.xlsx" )
For more model, can be adapted with do.call( rbind, list_of_results)
and either a for or lapply to generate the additional
columns... Depends on how you obtain your several models.
Best regards,
NB: note that, to avoid duplicate row names, terms with the same name
will be incremented - see the results of the example above. You can
avoid this by explicely add the term names in the data.frame ---
r1$Terms <- rownames( r1 ) --- and removing the row names of the final
result.
On Wed, Sep 25, 2019 at 01:33:46PM +0200, Mario Garrido wrote:
? Dear users,
? it is not such an statistical question but how to export results
? I fit several *lme* model s and I know how can I export the data to excel,
? this way:
? lme1 <- lme(Mean ~ x*y, data = Data, random = ~ 1|factor(ID))
? anova(lme1)->resultslme1
? And to export to excel since keep the data in ordered in rows/columns
? write.xlsx( resultslme1 ,"C:/Users/Desktop/resultslme1.xlsx")
?
? What I want to do is to export output from several lme at the same time,
? and adding the name/reference of the model. Something like this
? lme1
? numDF denDF F.value p.value
? (Intercept) 1 78 653,6152 0
? x 2 78 0,822612 0,443057
? y 2 39 0,479357 0,622781
? x:y 4 78 2,593825 0,042787
?
? lme2
? numDF denDF F.value p.value
? (Intercept) 1 78 653,6152 0
? x 2 78 0,822612 0,443057
? y 2 39 0,479357 0,622781
? x:y 4 78 2,593825 0,042787
?
?
? I tried with merge, abind, paste,... but I did not find the solution
?
? Thanks in advance
?
? --
? Mario Garrido Escudero, PhD
? Dr. Hadas Hawlena Lab
? Mitrani Department of Desert Ecology
? Jacob Blaustein Institutes for Desert Research
? Ben-Gurion University of the Negev
? Midreshet Ben-Gurion 84990 ISRAEL
?
? gaiarrido at gmail.com; gaadio at post.bgu.ac.il
? phone: (+972) 08-659-6854
?
? [[alternative HTML version deleted]]
?
? _______________________________________________
? R-sig-mixed-models at r-project.org mailing list
? https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models