Tammy Ma
2012-Dec-13 12:52 UTC
[R] How to create multiple country's data into multiple sheets of one excel
HI, I have large dataset of many countries. I have written the program to run through each country to generate one output for each country. I want to put the output like this: one sheet has output for one country. How do I achieve it by r. I have tried this: library(xlsx) write.xlsx(nnn, "vn.xlsx", sheetName="Sheet1") [1] but when I change sheetName="Sheet2" to add up another country into one sheet. it autimatically deleted which I have down on [1]. index<-unique(dataset$country) for (i in 1:length(index)){ data<-dataset[dataset$country==index[i],] (...) output<-dd #then how do I create each country's output into one sheet of one excel??? } Kind regards, Tammy [[alternative HTML version deleted]]
Anthony Damico
2012-Dec-13 13:13 UTC
[R] How to create multiple country's data into multiple sheets of one excel
use append = TRUE inside your write.xlsx() function On Thu, Dec 13, 2012 at 7:52 AM, Tammy Ma <metal_licaling@live.com> wrote:> > HI, > > > I have large dataset of many countries. I have written the program to run > through each country to generate one output for each country. I want to put > the output like this: > > one sheet has output for one country. How do I achieve it by r. > > I have tried this: > library(xlsx) > write.xlsx(nnn, "vn.xlsx", sheetName="Sheet1") [1] > > but when I change sheetName="Sheet2" to add up another country into one > sheet. it autimatically deleted which I have down on [1]. > > index<-unique(dataset$country) > for (i in 1:length(index)){ > > data<-dataset[dataset$country==index[i],] > (...) > output<-dd > #then how do I create each country's output into one sheet of one excel??? > > } > > > Kind regards, > Tammy > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
jim holtman
2012-Dec-13 13:57 UTC
[R] How to create multiple country's data into multiple sheets of one excel
I use the XLConnect package to write out multiple sheets to an Excel workbook On Thu, Dec 13, 2012 at 7:52 AM, Tammy Ma <metal_licaling at live.com> wrote:> > HI, > > > I have large dataset of many countries. I have written the program to run through each country to generate one output for each country. I want to put the output like this: > > one sheet has output for one country. How do I achieve it by r. > > I have tried this: > library(xlsx) > write.xlsx(nnn, "vn.xlsx", sheetName="Sheet1") [1] > > but when I change sheetName="Sheet2" to add up another country into one sheet. it autimatically deleted which I have down on [1]. > > index<-unique(dataset$country) > for (i in 1:length(index)){ > > data<-dataset[dataset$country==index[i],] > (...) > output<-dd > #then how do I create each country's output into one sheet of one excel??? > > } > > > Kind regards, > Tammy > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.
Seemingly Similar Threads
- Help on write.xlsx library(xlsx)
- leer ficheros excel en R en Ubuntu
- How to align group based on the common values of two columns in r
- How to search in each excel in my working dir and extract part information of one product in each country?
- The problem of readLines