Eric R
2007-Sep-13 21:21 UTC
[R] Export Step Function Coefficients to Spreadsheet or Text File
Hello, After I use the lm() function to perform a multiple linear regression, and then use the step function to eliminate variables that predict the weakest, I need to export the final equation to a spreadsheet or a text file. Below is some sample code. In the end I want to export the coefficients to a spreadsheet. Will you please direct me to the appropriate syntax? Thanks for your time, --Eric x <- read.csv('C:/path/*.csv', comment.char = "", nrows = 99, header = TRUE, row.names = 1) w <- lm(d ~ x1 + x2 + x3 + x4 + 1) step(w) Coefficients: (Intercept) x1 x2 x3 x4 4.834e-04 4.892e-01 4.698e-02 4.206e-05 -8.806e-03 write.csv(w, file = 'C:/path/*.csv', append = TRUE) The error I get is: Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class "lm" into a data.frame -- View this message in context: http://www.nabble.com/Export-Step-Function-Coefficients-to-Spreadsheet-or-Text-File-tf4438516.html#a12663777 Sent from the R help mailing list archive at Nabble.com.
D L McArthur
2007-Sep-13 22:38 UTC
[R] Export Step Function Coefficients to Spreadsheet or Text File
Eric R <busorafn <at> juno.com> writes:>... I want to export the coefficients to a spreadsheet....names(w) write.csv (w$coefficients, file=...) -- D L McArthur, UCLA Sch of Medicine, dmca <at> ucla.edu
Eric R
2007-Sep-14 04:18 UTC
[R] Export Step Function Coefficients to Spreadsheet or Text File
Thanks, this works great! --Eric D L McArthur wrote:> > Eric R <busorafn <at> juno.com> writes: >>... I want to export the coefficients to a spreadsheet.... > > names(w) > write.csv (w$coefficients, file=...) > > -- D L McArthur, UCLA Sch of Medicine, dmca <at> ucla.edu > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: http://www.nabble.com/Export-Step-Function-Coefficients-to-Spreadsheet-or-Text-File-tf4438516.html#a12668227 Sent from the R help mailing list archive at Nabble.com.