I have a number of data.frame
s that I want to export to Excel using the package XLConnect
. I'm doing this using a for
loop, within the loop there is a paste
function that gives the sheet
name but I don't know how to construct the data
name.
Here's what I mean.
My data.frame
s are named as follows,
port.1a, port.1b, port.2a, port.2b ... port.10a, port.10b
So far my code looks like this,
library(XLConnect)
for (i in 1:10){
a[i] <- paste("port.",i,"a",sep="")
b[i] <- paste("port.",i,"a",sep="")
writeWorksheetToFile("wfe_bx3.xlsx", data=b[i], sheet=a[i])
}
I haven't bother with the port.1b
data.frame
s as yet because I'm having difficulty with this part. Obviously, paste
returns a character
rather than a data.frame
for data=b
but cat
doesn't work either.
Any help would be appreciated, if only to tell me that this is a repeat question. (There are lots of similar questions but they haven't helped).