eugen pircalabelu
2010-Jul-13 20:21 UTC
[R] export tables to excel files on multiple sheets with titles for each table
Hello R-users, Checking the archives, I recently came across this topic: "export tables to Excel files" (http://r.789695.n4.nabble.com/export-tables-to-Excel-files-td1565679.html#a1565679), and the following interesting references have been proposed: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows http://www.r-bloggers.com/export-data-frames-to-multi-worksheet-excel-file-2/ but my problem is somehow a small extension to what has been discussed, and although i have a solution, i seek something more elegant. I want to export multiple dataframes (on multiple sheets), but i also want each of them to have its own title that is to be written also in Excel. The packages/functions that i have checked, cannot accommodate a title that is to be written on the sheet, along with the actual dataframe of interest. I can do something similar to what i need, but without writing the dataframes on multiple sheets. #head(USArrests) and head(iris) written with accompanying title one under each other write.excel<-function (tab, ...){ zz <- file("example.dat", "a+b") cat("\"TITLE extra line",file = zz, sep = "\n") write.table(tab, file=zz, row.names=F,sep="\t") close(zz)} write.excel(head(USArrests)) write.excel(head(iris)) Any suggestion on how to export the same information on two separate sheets, and keeping also a title for each of them, is highly appreciated, as i have been searching for some time for a good solution. Thank you very much and have a great day ahead! Eugen Pircalabelu (0032)471 842 140 (0040)727 839 293
Felipe Carrillo
2010-Jul-13 21:09 UTC
[R] export tables to excel files on multiple sheets with titles for each table
Check?the WriteXLS package,?I think it?does that and also saves each?R object on a different excel sheet. ? Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA ----- Original Message ----> From: eugen pircalabelu <eugen_pircalabelu at yahoo.com> > To: R-help <r-help at stat.math.ethz.ch> > Sent: Tue, July 13, 2010 1:21:33 PM > Subject: [R] export tables to excel files on multiple sheets with titles for >each table > > Hello R-users, > Checking the archives, I recently came across this topic: > "export tables to Excel files" >(http://r.789695.n4.nabble.com/export-tables-to-Excel-files-td1565679.html#a1565679), >, > and the following interesting references have been proposed: > http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows > http://www.r-bloggers.com/export-data-frames-to-multi-worksheet-excel-file-2/ > > but my problem is somehow a small extension to what has been discussed, and > although i have a solution, i seek something more elegant. I want to export > multiple dataframes (on multiple sheets), but i also want each of them to have> its own title that is to be written also in Excel. The packages/functions that >i > > have checked, cannot accommodate a title that is to be written on the sheet, > along with the actual dataframe of interest. > > I can do something similar to what i need, but without writing the dataframes >on > > multiple sheets. > > #head(USArrests) and head(iris) written with accompanying title one under each> other > > write.excel<-function (tab, ...){ > zz <- file("example.dat", "a+b") > cat("\"TITLE extra line",file = zz, sep = "\n") > write.table(tab, file=zz, row.names=F,sep="\t") > close(zz)} > write.excel(head(USArrests)) > write.excel(head(iris)) > > Any suggestion on how to export the same information on two separate sheets, >and > > keeping also a title for each of them, is highly appreciated, as i have been > searching for some time for a good solution. > > Thank you very much and have a great day ahead! > > > > > > > Eugen Pircalabelu > (0032)471 842 140 > (0040)727 839 293 > > ______________________________________________ > 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. >
Gabor Grothendieck
2010-Jul-13 22:24 UTC
[R] export tables to excel files on multiple sheets with titles for each table
On Tue, Jul 13, 2010 at 4:21 PM, eugen pircalabelu <eugen_pircalabelu at yahoo.com> wrote:> Hello R-users, > Checking the archives, I recently came across this topic: > "export tables to Excel files" > (http://r.789695.n4.nabble.com/export-tables-to-Excel-files-td1565679.html#a1565679), > ?and the following interesting references have been proposed: > http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows > http://www.r-bloggers.com/export-data-frames-to-multi-worksheet-excel-file-2/ > > but my problem is somehow a small extension to what has been discussed, and > although i have a solution, i seek something more elegant. I want to export > multiple dataframes (on multiple sheets), but i also want each of them to have > its own title that is to be written also in Excel. The packages/functions that i > have checked, cannot accommodate a title that is to be written on the sheet, > along with the actual dataframe of interest. >You might check through the packages listed here: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows&rev=1266947178
Whit Armstrong
2010-Jul-15 01:29 UTC
[R] export tables to excel files on multiple sheets with titles for each table
It isn't beautiful, but I use this package to write excel files from linux. http://github.com/armstrtw/Rexcelpoi the basic idea is that each element of a list is written as a separate sheet, but if a list element is itself a list, then all the elements of that list are written to the same sheet (with a title corresponding to the name of the list element). -Whit On Tue, Jul 13, 2010 at 4:21 PM, eugen pircalabelu <eugen_pircalabelu at yahoo.com> wrote:> Hello R-users, > Checking the archives, I recently came across this topic: > "export tables to Excel files" > (http://r.789695.n4.nabble.com/export-tables-to-Excel-files-td1565679.html#a1565679), > ?and the following interesting references have been proposed: > http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows > http://www.r-bloggers.com/export-data-frames-to-multi-worksheet-excel-file-2/ > > but my problem is somehow a small extension to what has been discussed, and > although i have a solution, i seek something more elegant. I want to export > multiple dataframes (on multiple sheets), but i also want each of them to have > its own title that is to be written also in Excel. The packages/functions that i > have checked, cannot accommodate a title that is to be written on the sheet, > along with the actual dataframe of interest. > > I can do something similar to what i need, but without writing the dataframes on > multiple sheets. > > #head(USArrests) and head(iris) written with accompanying title one under each > other > > write.excel<-function (tab, ...){ > ?zz <- file("example.dat", "a+b") > ?cat("\"TITLE extra line",file = zz, sep = "\n") > ?write.table(tab, file=zz, row.names=F,sep="\t") > ?close(zz)} > ?write.excel(head(USArrests)) > ?write.excel(head(iris)) > > Any suggestion on how to export the same information on two separate sheets, and > keeping also a title for each of them, is highly appreciated, as i have been > searching for some time for a good solution. > > Thank you very much and have a great day ahead! > > > > > > > ?Eugen Pircalabelu > (0032)471 842 140 > (0040)727 839 293 > > ______________________________________________ > 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. >