[R] How to create multiple country's data into multiple sheets of one excel

2012-12-13 Thread Tammy Ma

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.


Re: [R] How to create multiple country's data into multiple sheets of one excel

2012-12-13 Thread Anthony Damico
use append = TRUE inside your write.xlsx() function


On Thu, Dec 13, 2012 at 7:52 AM, Tammy Ma metal_lical...@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]]

__
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.


Re: [R] How to create multiple country's data into multiple sheets of one excel

2012-12-13 Thread jim holtman
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_lical...@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.



-- 
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.

__
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.