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

jim holtman jholtman at gmail.com
Thu Dec 13 14:57:58 CET 2012


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.




More information about the R-help mailing list