googlesheets (version 0.3.0)

gs_read_cellfeed: Read data from cells

Description

This function consumes data via the "cell feed", which, as the name suggests, retrieves data cell by cell. Note that the output is a data frame with one row per cell. Consult the Google Sheets API documentation for more details about the cell feed.

Usage

gs_read_cellfeed(ss, ws = 1, range = NULL, ..., return_empty = FALSE,
  return_links = FALSE, 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 to control data download, parsing, and reshaping; for most purposes, the defaults should be fine. Anything that is not listed here will be silently ignored.

progress

Logical. Whether to display download progress if in an interactive session.

col_types

Seize control of type conversion for variables. Passed straight through to readr::read_csv or readr::type_convert. Follow those links or read the vignette("column-types") for details.

locale, trim_ws, na

Specify locale, the fate of leading or trailing whitespace, or a character vector of strings that should become missing values. Passed straight through to readr::read_csv or readr::type_convert.

comment, skip, n_max

Specify a string used to identify comments, request to skip lines before reading data, or specify the maximum number of data rows to read.

col_names

Either TRUE, FALSE or a character vector of column names. If TRUE, the first row of the data rectangle will be used for names. If FALSE, column names will be X1, X2, etc. If a character vector, it will be used as column names. If the sheet contains column names and you just don't like them, specify skip = 1 so they don't show up in your data.

check.names

Logical. Whether to run column names through make.names with unique = TRUE, just like read.table does. By default, googlesheets implements the readr data ingest philosophy, which leaves column names "as is", with one exception: data frames returned by googlesheets will have a name for each variable, even if we have to create one.

return_empty

logical; indicates whether to return empty cells

return_links

logical; indicates whether to return the edit and self links (used internally in cell editing workflow)

verbose

logical; do you want informative messages?

Value

a data.frame or, if dplyr is loaded, a tbl_df

Details

Use the range argument to specify which cells you want to read. See the examples and the help file for the cell specification functions for various ways to limit consumption to, e.g., a rectangle or certain columns. If range is specified, the associated cell limits will be checked for internal consistency and compliance with the known extent of the worksheet. If no limits are provided, all cells will be returned but consider that gs_read_csv and gs_read_listfeed are much faster ways to consume all the data from a rectangular worksheet.

Empty cells, even if "embedded" in a rectangular region of populated cells, are not normally returned by the cell feed. This function won't return them either when return_empty = FALSE (default), but will if you set return_empty = TRUE.

See Also

gs_reshape_cellfeed or gs_simplify_cellfeed to perform reshaping or simplification, respectively; gs_read is a pre-made wrapper that combines gs_read_cellfeed and gs_reshape_cellfeed

Other data consumption functions: gs_read_csv, gs_read_listfeed, gs_read, gs_reshape_cellfeed, gs_simplify_cellfeed

Examples

Run this code
# NOT RUN {
gap_ss <- gs_gap() # register the Gapminder example sheet
col_4_and_above <-
  gs_read_cellfeed(gap_ss, ws = "Asia", range = cell_limits(c(NA, 4)))
col_4_and_above
gs_reshape_cellfeed(col_4_and_above)

gs_read_cellfeed(gap_ss, range = "A2:F3")
# }

Run the code above in your browser using DataCamp Workspace