Learn R Programming

googlesheets (version 0.2.0)

gs_reshape_cellfeed: Reshape data from the "cell feed"

Description

Reshape data from the "cell feed", put it in a tbl_df, and do type conversion. By default, assuming we're working with the same cells, gs_reshape_cellfeed should return the same result as other read functions. But when literal = FALSE, something different happens: we attempt to deliver cell contents free of any numeric formatting. Try this if numeric formatting of literal values is causing numeric data to come in as character, to be undesirably rounded, or to be otherwise mangled. Remember you can also control type conversion by using ... to provide arguments to readr::type_convert. See the vignette("formulas-and-formatting") for more details.

Usage

gs_reshape_cellfeed(x, literal = TRUE, ..., verbose = TRUE)

Arguments

x
a data frame returned by gs_read_cellfeed
literal
logical, indicating whether to work only with literal values returned by the API or to consult alternate cell contents
...
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. [object Object],[object Object],[object Object],[object Ob
verbose
logical; do you want informative messages?

Value

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

See Also

Other data.consumption.functions: gs_read_cellfeed, gs_read_csv, gs_read_listfeed, gs_read, gs_simplify_cellfeed

Examples

Run this code
gap_ss <- gs_gap() # register the Gapminder example sheet
gs_read_cellfeed(gap_ss, "Asia", range = cell_rows(1:4))
gs_reshape_cellfeed(gs_read_cellfeed(gap_ss, "Asia", range = cell_rows(1:4)))
gs_reshape_cellfeed(gs_read_cellfeed(gap_ss, "Asia",
                                     range = cell_rows(2:4)),
                    col_names = FALSE)
gs_reshape_cellfeed(gs_read_cellfeed(gap_ss, "Asia",
                                     range = cell_rows(2:4)),
                    col_names = paste0("yo", 1:6))

ff_ss <- gs_ff() # register example sheet with formulas and formatted nums
ff_cf <- gs_read_cellfeed(ff_ss)
gs_reshape_cellfeed(ff_cf) # almost all vars are character
gs_reshape_cellfeed(ff_cf, literal = FALSE) # more vars are numeric

Run the code above in your browser using DataLab