Print or capturing multiple objects in R

后端 未结 2 1520
走了就别回头了
走了就别回头了 2021-01-15 06:04

I have multiple regressions in an R script and want to append the regression summaries to a single text file output. I know I can use the following code to do this for one

2条回答
  •  深忆病人
    2021-01-15 06:43

    You can store the result as a list and then use the capture.output

    fit1<-lm(mpg~cyl,data=mtcars)
    fit2<-lm(mpg~cyl+disp,data=mtcars)
    myresult<-list(fit1,fit2)
    capture.output(myresult, file = "results.txt")
    

提交回复
热议问题