Exporting R lm regression with cbind to text

前端 未结 2 1015
感情败类
感情败类 2021-01-23 06:19

I have the following lm with a vector of dependent variables:

> fit<-lm(cbind(X1m, X3m, X6m, X1y, X2y, X3y, X5y, X6y, X10y, 
                     X20y, X         


        
2条回答
  •  忘了有多久
    2021-01-23 07:20

    I've found tidy in the broom package useful for this:

    fit <- lm(y ~ x, data.frame(x=1:10, y=rnorm(10))) # dummy example
    
    library(broom)
    tidy(fit)
    
    # result is a data.frame:
    #         term   estimate std.error  statistic   p.value
    #1 (Intercept) -0.3317979 1.2034887 -0.2756967 0.7897685
    #2           x -0.0663678 0.1939598 -0.3421730 0.7410364
    

提交回复
热议问题