I use RGoogleDocs a lot. I use it to read in data that is private or only shared with a few people. I know that read.table
and read.csv
allow one to use stringsAsFactors=FALSE
.
I want to do something similar in RGoogleDocs. Here is my typical code
sheets.con <- getGoogleDocsConnection(getGoogleAuth("[email protected]", ps, service ="wise"))
spreadsheet <- getWorksheets("private spreadsheet",sheets.con)
first <- sheetAsMatrix(spreadsheet$"Sheet 1",header=TRUE, as.data.frame=TRUE, trim=TRUE) #Get one sheet
That almost always reads the character values as factors. I have been using data.table a lot lately and factors seem to make my data munging in data.table a bit bothersome. Is there an easy way to read the non-numeric columns as character vectors rather than as factors?
Duncan Temple Lang, the writer of RGoogleDocs updated the package to 0.7-0. He added
stringsAsFactors
to thegetWorksheets()
andsheetAsMatrix()
function.Here is how you can get it into your R.
Now my line is