googlesheets (version 0.1.0)

gs_simplify_cellfeed: Simplify data from the cell feed

Description

In some cases, you do not want to convert the data retrieved from the cell feed into a data.frame via gs_reshape_cellfeed. Instead, you want the data as an atomic vector. That's what this function does. Note that, unlike gs_reshape_cellfeed, embedded empty cells will NOT necessarily appear in this result. By default, the API does not transmit data for these cells; googlesheets inserts these cells in gs_reshape_cellfeed because it is necessary to give the data rectangular shape. In contrast, empty cells will only appear in the output of gs_simplify_cellfeed if they were already present in the data from the cell feed, i.e. if the original call to gs_read_cellfeed had argument return_empty set to TRUE.

Usage

gs_simplify_cellfeed(x, convert = TRUE, as.is = TRUE, na.strings = "NA",
  notation = c("A1", "R1C1", "none"), col_names = NULL)

Arguments

x
a data.frame returned by gs_read_cellfeed
convert
logical, indicating whether to attempt to convert the result vector from character to something more appropriate, such as logical, integer, or numeric; if TRUE, result is passed through type.convert; if FALSE, result will be character
as.is
logical, passed through to the as.is argument of type.convert
na.strings
a character vector of strings which are to be interpreted as NA values
notation
character; the result vector can have names that reflect which cell the data came from; this argument selects between the "A1" and "R1C1" positioning notations; specify "none" to suppress names
col_names
if TRUE, the first row of the input will be interpreted as a column name and NOT included in the result; useful when reading a single column or variable

Value

  • a vector

See Also

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

Examples

Run this code
gap_ss <- gs_gap() # register the Gapminder example sheet
gs_read_cellfeed(gap_ss, range = cell_rows(1))
gs_simplify_cellfeed(gs_read_cellfeed(gap_ss, range = cell_rows(1)))
gs_simplify_cellfeed(
  gs_read_cellfeed(gap_ss, range = cell_rows(1)), notation = "R1C1")

gs_read_cellfeed(gap_ss, range = "A1:A10")
gs_simplify_cellfeed(gs_read_cellfeed(gap_ss, range = "A1:A10"))
gs_simplify_cellfeed(gs_read_cellfeed(gap_ss, range = "A1:A10"),
                     col_names = FALSE)

Run the code above in your browser using DataCamp Workspace