Reshapes a data frame of cells (presumably the output of
range_read_cells()) into another data frame, i.e., puts it back into the
shape of the source spreadsheet. This function exists primarily for internal
use and for testing. The flagship function range_read(), a.k.a.
read_sheet(), is what most users are looking for. It is basically
range_read_cells() + spread_sheet().
Arguments
- df
A data frame with one row per (nonempty) cell, integer variables
rowandcolumn(probably referring to location within the spreadsheet), and a list-columncellofSHEET_CELLobjects.- col_names
TRUEto use the first row as column names,FALSEto get default names, or a character vector to provide column names directly. If user providescol_types,col_namescan have one entry per column or one entry per unskipped column.- col_types
Column types. Either
NULLto guess all from the spreadsheet or a string of readr-style shortcodes, with one character or code per column. If exactly onecol_typeis specified, it is recycled. See Column Specification for more.- na
Character vector of strings to interpret as missing values. By default, blank cells are treated as missing data.
- trim_ws
Logical. Should leading and trailing whitespace be trimmed from cell contents?
- guess_max
Maximum number of data rows to use for guessing column types.
- .name_repair
Handling of column names. By default, googlesheets4 ensures column names are not empty and are unique. There is full support for
.name_repairas documented intibble::tibble().
Value
A tibble in the shape of the original spreadsheet, but enforcing
user's wishes regarding column names, column types, NA strings, and
whitespace trimming.
Examples
if (FALSE) { # gs4_has_token()
df <- gs4_example("mini-gap") %>%
range_read_cells()
spread_sheet(df)
# ^^ gets same result as ...
read_sheet(gs4_example("mini-gap"))
}
