googlesheets (version 0.1.0)

gs_read: Read data

Description

This function reads data from a worksheet and returns it as a tbl_df or data.frame. It wraps up the most common usage of other, lower-level functions for data consumption and transformation, but you can call always call them directly for finer control.

Usage

gs_read(ss, ws = 1, range = NULL, ..., 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
range
a cell range, as described in cell-specification
...
optional arguments passed on to functions that control reading and transforming the data
verbose
logical; do you want informative messages?

Value

  • a tbl_df

Details

If the range argument is not specified, all data will be read via gs_read_csv. In this case, you can pass additional arguments to the csv parser via ...; see gs_read_cellfeed for more details. Don't worry -- no intermediate *.csv files were written in the reading of your data! We just request the data from the Sheets API via the exportcsv link.

If the range argument is specified, data will be read for the targetted cells via gs_read_cellfeed, then reshaped with gs_reshape_cellfeed. In this case, you can pass additional arguments to gs_reshape_cellfeed via ....

See Also

The cell-specification topic for more about targetting specific cells.

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

Examples

Run this code
gap_ss <- gs_gap()
oceania_csv <- gs_read(gap_ss, ws = "Oceania")
str(oceania_csv)
oceania_csv

gs_read(gap_ss, ws = "Oceania", range = "A1:C4")
gs_read(gap_ss, ws = "Oceania", range = "R1C1:R4C3")
gs_read(gap_ss, ws = "Oceania", range = "R2C1:R4C3", col_names = FALSE)
gs_read(gap_ss, ws = "Oceania", range = "R2C5:R4C6",
        col_names = c("thing_one", "thing_two"))
gs_read(gap_ss, ws = "Oceania", range = cell_limits(c(1, 4), c(1, 3)))
gs_read(gap_ss, ws = "Oceania", range = cell_rows(1:5))
gs_read(gap_ss, ws = "Oceania", range = cell_cols(4:6))
gs_read(gap_ss, ws = "Oceania", range = cell_cols("A:D"))
gs_read(gap_ss, ws = "Oceania", range = cell_rows(1), col_names = FALSE)

Run the code above in your browser using DataLab