[R] Saving Google worksheets with common prefix

Jennifer Sabatier plessthanpointohfive at gmail.com
Fri Nov 21 17:19:48 CET 2014


I got it!


for (i in sheetz$names) {
print(i)
file.name <- paste(i, " - ", Sys.Date(), ".csv", sep="")
print(file.name)
#traceback()
i <- sheetAsMatrix(ts[[i]], header = TRUE, as.data.frame = TRUE, trim =
TRUE)
write.csv(i, file.name)
i
}

I have to use ts[[i]] rather than ts$i (or ts2, either)

Thanks!

Jen

PS - if anyone wants to use that code and that dummy gmail account to play
around with R, that's fine - be my guest.  The email address is hidden but
it's "r dot project dot user at gmail dot com" and the password is in the
code.  Upload your own data and play, if you like.




On Fri, Nov 21, 2014 at 11:02 AM, Jennifer Sabatier <
plessthanpointohfive at gmail.com> wrote:

>
> On Fri, Nov 21, 2014 at 10:36 AM, Henrik Bengtsson <hb at biostat.ucsf.edu>
> wrote:
>
>> print(ts2$i)
>
>
>
> You're right.  It's not doing what I think it's supposed to be doing.  The
> print(ts2$i) gives NULL:
>
>
> [1] "Cash Flows211"
> NULL
> [1] "Cash Flows211 - 2014-11-21.csv"
> 7: getURL(sheet at cellsfeed, curl = getCurlCon(con), followlocation = TRUE)
> 6: getCells(sheet, con = con)
> 5: xmlParse(getCells(sheet, con = con))
> 4: xpathApply(doc, path, fun, ..., namespaces = namespaces,
> sessionEncoding = sessionEncoding,
>        addFinalizer = addFinalizer)
> 3: getNodeSet(doc, "//a:entry/gs:cell", c(a = "http://www.w3.org/2005/Atom",
>
>        gs = "http://schemas.google.com/spreadsheets/2006"))
> 2: processCells2(doc, trim, header, as.data.frame, stringsAsFactors =
> stringsAsFactors)
> 1: sheetAsMatrix(ts$i, header = TRUE, as.data.frame = TRUE, trim = TRUE)
> at #7
> Error in getURL(sheet at cellsfeed, curl = getCurlCon(con), followlocation =
> TRUE) :
>   trying to get slot "cellsfeed" from an object of a basic class ("NULL")
> with no slots
>
> So, I've got to figure out how to feed that list of names properly.
>
> Thanks!
>
> Jen
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list