I am trying to export the output of my regression model into a .txt or .csv file. I was able to export the main information from summary() the terms (e.g., intercept), p-values etc. However, the exported file does not give me residuals standard information, R2 and F statistics, which appears at the bottom of the output.
Here is the code that I am using
model = lm(cs~group + sex, data = metadata) #adjusting for sex.
Output
Call: lm(formula = cs ~ group + sex, data = metadata)
Residuals: Min 1Q Median 3Q Max -16.917 -7.733 -2.506 6.934 32.494
Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 14.051 3.767 3.731 0.000555 * groupHFD -3.987 4.853 -0.822 0.415880 groupHFD +Exe 1.571 4.853 0.324 0.747817 groupHFD+Exe+Gen 4.874 4.989 0.977 0.334131 groupHFD+Gen -1.189 4.853 -0.245 0.807610 sexMale 9.633 3.104 3.103 0.003378
--- Signif. codes: 0 ‘*’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Residual standard error: 10.85 on 43 degrees of freedom Multiple R-squared: 0.2286, Adjusted R-squared: 0.139 F-statistic: 2.549 on 5 and 43 DF, p-value: 0.04168
#Save the regression output as table in cvs table.
write.table(csregression, file = 'csregression.csv', sep = ",", row.names = F, col.names = T)
The .csv file shows the following
Estimate Std. Error t value Pr(>|t|) (Intercept) 14.051 3.767 3.731 0.000555 groupHFD
-3.987 4.853 -0.822 0.415880 groupHFD +Exe 1.571 4.853 0.324 0.747817 groupHFD+Exe+Gen 4.874 4.989 0.977 0.334131 groupHFD+Gen -1.189 4.853 -0.245 0.807610 sexMale 9.633 3.104 3.103 0.003378
Does someone experience the same issue? How could I export the information missing, the F-statistic and R-squared information?