googlesheets (version 0.1.0)

gs_read_csv: Read data via the exportcsv link

Description

This function reads all data from a worksheet and returns it as a tbl_df or data.frame. Don't be spooked by the "csv" thing -- the data is NOT actually written to file during this process. Data is read from the "maximal data rectangle", i.e. the rectangle spanned by the maximal row and column extent of the data. Empty cells within this rectangle will be assigned NA. This is the fastest method of data consumption, so use it as long as you can tolerate the lack of control re: which cells are being read.

Usage

gs_read_csv(ss, ws = 1, ..., verbose = TRUE)

Arguments

ss
a registered Google spreadsheet, i.e. a googlesheet object
ws
positive integer or character string specifying index or title, respectively, of the worksheet
...
Further arguments to be passed to the csv parser. This is currently read.csv, but expect a switch to readr::read_csv in the not-too-distant future! Note that by default
verbose
logical; do you want informative messages?

Value

  • a tbl_df

Details

How does this compare to consumption via the list feed, implemented by gs_read_listfeed? First, gs_read_csv is much, much faster. Second, the first row, potentially containing column or variable names, is NOT transformed/mangled, as it is via the list feed. Finally, consumption via the exportcsv link is more tolerant of data that does not form a perfect, neat rectangle, e.g. the read does NOT stop upon encountering an empty row.

See Also

Other data.consumption.functions: gs_read_cellfeed; gs_read_listfeed; gs_read; gs_reshape_cellfeed; gs_simplify_cellfeed

Examples

Run this code
gap_ss <- gs_gap() # register the Gapminder example sheet
oceania_csv <- gs_read_csv(gap_ss, ws = "Oceania")
str(oceania_csv)
oceania_csv

Run the code above in your browser using DataLab