Hi Duncan Thank you so much - it worked :) Best Livia ________________________________________ Fra: Duncan Mackay [dulcalma at bigpond.com] Sendt: 6. maj 2015 14:26 Til: R; Livia Maria Vestergaard Emne: RE: [R] lm model exported from R to excel Hi Livia There are several html packages that ?could also do it Heres a way with xtable library(xtable) y = rnorm(100) x= rnorm(100)+rnorm(100) mod <- lm(y ~x) # latex example easy view xtable(mod) # html file.create("lm.htm") ff <- file("lm.htm", "a+") fchars <- print(xtable(mod),type = "html") writeLines(paste(fchars, sep = ""), ff) close(ff) You can then bring this into Microsoft as an html file You may need to fill in some of the arguments in xtable to get the right border format etc If you are doing many you can make a function to do things Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mackay at northnet.com.au -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Livia Maria Vestergaard Sent: Wednesday, 6 May 2015 19:37 To: r-help Subject: [R] lm model exported from R to excel Hi all I all. I am wondering whether anybody know how to export an output of an lm model from R to excel in order to have excel recognize the table that comes and divide the numbers in the table into columns and rows? I really hope it is possible? :) Best Livia ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
If you know some basic html language you can jazz up the table headings to your liking by writing that before the xtable statement. It save having to muck around in Microsoft to fix it. If you are going to do a lot of it - a little study of html basics can go far. I was changing the headings to what I wanted using html (although not all the tables were lm summaries) before the major upgrade a year or so ago Now things are better. Even a title and comments in html for yourself if not available in xtable are helpful. I have not used xtable and html since the upgrade as I use latex Duncan -----Original Message----- From: Livia Maria Vestergaard [mailto:lvest09 at student.sdu.dk] Sent: Wednesday, 6 May 2015 22:37 To: Duncan Mackay; R Subject: SV: [R] lm model exported from R to excel Hi Duncan Thank you so much - it worked :) Best Livia ________________________________________ Fra: Duncan Mackay [dulcalma at bigpond.com] Sendt: 6. maj 2015 14:26 Til: R; Livia Maria Vestergaard Emne: RE: [R] lm model exported from R to excel Hi Livia There are several html packages that ?could also do it Heres a way with xtable library(xtable) y = rnorm(100) x= rnorm(100)+rnorm(100) mod <- lm(y ~x) # latex example easy view xtable(mod) # html file.create("lm.htm") ff <- file("lm.htm", "a+") fchars <- print(xtable(mod),type = "html") writeLines(paste(fchars, sep = ""), ff) close(ff) You can then bring this into Microsoft as an html file You may need to fill in some of the arguments in xtable to get the right border format etc If you are doing many you can make a function to do things Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mackay at northnet.com.au -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Livia Maria Vestergaard Sent: Wednesday, 6 May 2015 19:37 To: r-help Subject: [R] lm model exported from R to excel Hi all I all. I am wondering whether anybody know how to export an output of an lm model from R to excel in order to have excel recognize the table that comes and divide the numbers in the table into columns and rows? I really hope it is possible? :) Best Livia ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
If you are trying to save the html version of the table, Duncan's example can be simplified to> print(xtable(mod), type="html", file="lm.html")Open this file in Excel or Word. Alternatively open it in your browser and paste it into Word or Excel. If you are using Windows and Excel, you can streamline this a bit more by using the Windows clipboard:> print(xtable(mod), type="html", file="clipboard")Open an Excel spreadsheet and then paste the table into it. For some reason, this will not work with Word. You have to paste into Excel, copy the table in Excel, and then paste into Word. ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Livia Maria Vestergaard Sent: Wednesday, May 6, 2015 7:37 AM To: Duncan Mackay; R Subject: Re: [R] lm model exported from R to excel Hi Duncan Thank you so much - it worked :) Best Livia ________________________________________ Fra: Duncan Mackay [dulcalma at bigpond.com] Sendt: 6. maj 2015 14:26 Til: R; Livia Maria Vestergaard Emne: RE: [R] lm model exported from R to excel Hi Livia There are several html packages that ?could also do it Heres a way with xtable library(xtable) y = rnorm(100) x= rnorm(100)+rnorm(100) mod <- lm(y ~x) # latex example easy view xtable(mod) # html file.create("lm.htm") ff <- file("lm.htm", "a+") fchars <- print(xtable(mod),type = "html") writeLines(paste(fchars, sep = ""), ff) close(ff) You can then bring this into Microsoft as an html file You may need to fill in some of the arguments in xtable to get the right border format etc If you are doing many you can make a function to do things Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mackay at northnet.com.au -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Livia Maria Vestergaard Sent: Wednesday, 6 May 2015 19:37 To: r-help Subject: [R] lm model exported from R to excel Hi all I all. I am wondering whether anybody know how to export an output of an lm model from R to excel in order to have excel recognize the table that comes and divide the numbers in the table into columns and rows? I really hope it is possible? :) Best Livia ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.