How to export dataframes to xls
3
0
Entering edit mode
pankaj borah ▴ 120
@pankaj-borah-3804
Last seen 10.2 years ago
I have a     dataframe containing 104 columns and 30,000 rows.  I want to extract 104 columns to a single excel file as separate spreadsheet . Again each of the 104  columns are named  as say A1, A2, A3 ; B1,B2,B3; C1,C2,C3 in the dataframeetc. So, instead of exporting to 104 spreadsheets I want to export all the A , B, and C columns to a single spreadsheet. How do I do that? I am a learner in R" and not an expert. Thanks, Pankaj Barah Department of Biology, Norwegian University of Science & Technology (NTNU)  Realfagbygget, N-7491 Trondheim, Norway [[alternative HTML version deleted]]
• 1.9k views
ADD COMMENT
0
Entering edit mode
@achilleas-pitsillides-4316
Last seen 10.2 years ago
Hey Pankaj, Have you tried using the xlsReadWrite package. I am not on windows so I can't really test it out but after installing the package something of the form should work. for (column.index in 1:ncol(data)){ write.xls(data[,column.index],"xlfile.xls", sheet=column.index) } Good luck, Achilleas On Thu, Nov 18, 2010 at 11:11 AM, pankaj borah <pankajborah2k3@yahoo.co.in>wrote: > > > > > > I have a dataframe containing 104 columns and 30,000 rows. I want > to extract 104 columns to a single excel file as separate spreadsheet . > > Again each of the 104 columns are named as say A1, A2, A3 ; > B1,B2,B3; C1,C2,C3 in the dataframeetc. So, instead of exporting to 104 > spreadsheets I > want to export all the A , B, and C columns to a single spreadsheet. > > > > How do I do that? I am a learner in R" and not an expert. > > > > Thanks, > > Pankaj Barah > > Department of Biology, > Norwegian University of Science & Technology (NTNU) > Realfagbygget, N-7491 Trondheim, Norway > > > > [[alternative HTML version deleted]] > > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > [[alternative HTML version deleted]]
ADD COMMENT
0
Entering edit mode
markus.boenn ▴ 50
@markusboenn-6784
Last seen 10.2 years ago
European Union
Hello Pankaj, as far as I know there is a write.xls function in R included in package "marray". However, i think this function only creates a .csv-file with an .xls-suffix. Further (better) possible options might be the routines provided by the packages "WriteXLS" or "gdata". Hope this helps. Markus pankaj borah wrote: > > > > I have a dataframe containing 104 columns and 30,000 rows. I want > to extract 104 columns to a single excel file as separate spreadsheet . > > Again each of the 104 columns are named as say A1, A2, A3 ; > B1,B2,B3; C1,C2,C3 in the dataframeetc. So, instead of exporting to 104 spreadsheets I > want to export all the A , B, and C columns to a single spreadsheet. > > > > How do I do that? I am a learner in R" and not an expert. > > > > Thanks, > > Pankaj Barah > > Department of Biology, > Norwegian University of Science & Technology (NTNU) > Realfagbygget, N-7491 Trondheim, Norway > > > > [[alternative HTML version deleted]] > > > -------------------------------------------------------------------- ---- > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- Diplom-Bioinform. Markus B?nn Martin-Luther-Universit?t Halle-Wittenberg Naturwissenschaftliche Fakult?t III Institut f?r Informatik von-Seckendorff-Platz 1 06120 Halle (Saale)
ADD COMMENT
0
Entering edit mode
In package 'xlsx' there is write.xlsx which will do what the OP wishes. On Fri, Nov 19, 2010 at 12:54 AM, Markus Boenn < boenn@informatik.uni-halle.de> wrote: > Hello Pankaj, > > as far as I know there is a write.xls function in R included in package > "marray". However, i think this function only creates a .csv-file with an > .xls-suffix. > > Further (better) possible options might be the routines provided by the > packages "WriteXLS" or "gdata". > > Hope this helps. > > Markus > > > pankaj borah wrote: > >> >> >> >> I have a dataframe containing 104 columns and 30,000 rows. I want to >> extract 104 columns to a single excel file as separate spreadsheet . >> Again each of the 104 columns are named as say A1, A2, A3 ; B1,B2,B3; >> C1,C2,C3 in the dataframeetc. So, instead of exporting to 104 spreadsheets I >> want to export all the A , B, and C columns to a single spreadsheet. >> >> >> How do I do that? I am a learner in R" and not an expert. >> >> >> Thanks, >> >> Pankaj Barah >> >> Department of Biology, Norwegian University of Science & Technology (NTNU) >> Realfagbygget, N-7491 Trondheim, Norway >> >> >> [[alternative HTML version deleted]] >> >> ------------------------------------------------------------------ ------ >> >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor@stat.math.ethz.ch >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: >> http://news.gmane.org/gmane.science.biology.informatics.conductor >> > > > -- > Diplom-Bioinform. Markus Bönn > Martin-Luther-Universität Halle-Wittenberg > Naturwissenschaftliche Fakultät III > Institut für Informatik > von-Seckendorff-Platz 1 > 06120 Halle (Saale) > > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > -- If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is. John von Neumann<http: www-groups.dcs.st-="" and.ac.uk="" ~history="" biographies="" von_neumann.html=""> [[alternative HTML version deleted]]
ADD REPLY
0
Entering edit mode
@january-weiner-3999
Last seen 10.2 years ago
Dear Pankaj, why don't you just write a CSV (comma- or tab separated) plain text file? Excel will happily read it and import it into a single spreadsheet. For this, you don't need anything beyond the standard "write.table" function. You can write to an xls file, so that -- on a Windows machine -- it opens automatically with Excel: write.table( SomeDataFrame, file= "mydataframe.xls", sep= "\t", quote= F ) Here, I use "tab" as the separator and no quotes around string data / factor names. Cheers, j. On Thu, Nov 18, 2010 at 5:11 PM, pankaj borah <pankajborah2k3 at="" yahoo.co.in=""> wrote: > > > > > > I have a ??? dataframe containing 104 columns and 30,000 rows.? I want > to extract 104 columns to a single excel file as separate spreadsheet . > > Again each of the 104? columns are named? as say A1, A2, A3 ; > B1,B2,B3; C1,C2,C3 in the dataframeetc. So, instead of exporting to 104 spreadsheets I > want to export all the A , B, and C columns to a single spreadsheet. > > > > How do I do that? I am a learner in R" and not an expert. > > > > Thanks, > > Pankaj Barah > > Department of Biology, > Norwegian University of Science & Technology (NTNU) > ?Realfagbygget, N-7491 Trondheim, Norway > > > > ? ? ? ?[[alternative HTML version deleted]] > > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- -------- Dr. January Weiner 3 -------------------------------------- Max Planck Institute for Infection Biology Charit?platz 1 D-10117 Berlin, Germany Web?? : www.mpiib-berlin.mpg.de Tel? ?? : +49-30-28460514
ADD COMMENT

Login before adding your answer.

Traffic: 769 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6