[R-sig-ME] Export several lme outputs to a single excel file

Mario Garrido g@@d|o @end|ng |rom po@t@bgu@@c@||
Tue Oct 8 10:28:45 CEST 2019


Dear Emmanuel Curis,
your approach was working perfectly, but at some point w gives me the
error. when introduced the new column
I have no problem in running model, the errors appears when introducing
extra $Md column. I wonder whether the problem is the * of the
significance, but is not, also is not due to character strings since my
variables are recognized as factors. I have no missing data in my
matrix,... And, as I said, problem only arise when I introduced the new
column

Thanks in advanxe
> anova(TempLight_StdzDiff_3trt_earlypeak)-> r15
> r15
Analysis of Variance Table

Response: StdzDiff
          Df  Sum Sq Mean Sq F value  Pr(>F)
Trtmnt     2   0.991  0.4953  0.2382 0.78891
sp         2  13.781  6.8904  3.3134 0.04407 *
Trtmnt:sp  4   4.123  1.0306  0.4956 0.73898
Residuals 53 110.217  2.0796
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> r15$Md<- "TempLight_StdzDiff_3trt_earlypeak"
> r15
Analysis of Variance Table

Response: StdzDiff
          Df  Sum Sq Mean Sq F value  Pr(>F) Md
Trtmnt     2   0.991  0.4953  0.2382 0.78891
sp         2  13.781  6.8904  3.3134 0.04407
Trtmnt:sp  4   4.123  1.0306  0.4956 0.73898
Residuals 53 110.217  2.0796
Warning message:
In data.matrix(x) : NAs introducidos por coerción



El mié., 25 sept. 2019 a las 22:55, Emmanuel Curis (<
emmanuel.curis using parisdescartes.fr>) escribió:

> 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 using gmail.com; gaadio using post.bgu.ac.il
> « phone: (+972) 08-659-6854
> «
> «       [[alternative HTML version deleted]]
> «
> « _______________________________________________
> « R-sig-mixed-models using r-project.org mailing list
> « https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> --
>                                 Emmanuel CURIS
>                                 emmanuel.curis using parisdescartes.fr
>
> Page WWW: http://emmanuel.curis.online.fr/index.html
>


-- 
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 using gmail.com; gaadio using post.bgu.ac.il
phone: (+972) 08-659-6854

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list