Skip to content

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().


  col_names = TRUE,
  col_types = NULL,
  na = "",
  trim_ws = TRUE,
  guess_max = min(1000, max(df$row)),
  .name_repair = "unique"



A data frame with one row per (nonempty) cell, integer variables row and column (probably referring to location within the spreadsheet), and a list-column cell of SHEET_CELL objects.


TRUE to use the first row as column names, FALSE to get default names, or a character vector to provide column names directly. If user provides col_types, col_names can have one entry per column or one entry per unskipped column.


Column types. Either NULL to guess all from the spreadsheet or a string of readr-style shortcodes, with one character or code per column. If exactly one col_type is specified, it is recycled. See Column Specification for more.


Character vector of strings to interpret as missing values. By default, blank cells are treated as missing data.


Logical. Should leading and trailing whitespace be trimmed from cell contents?


Maximum number of data rows to use for guessing column types.


Handling of column names. By default, googlesheets4 ensures column names are not empty and are unique. There is full support for .name_repair as documented in tibble::tibble().


A tibble in the shape of the original spreadsheet, but enforcing user's wishes regarding column names, column types, NA strings, and whitespace trimming.


if (gs4_has_token()) {
  df <- gs4_example("mini-gap") %>%

  # ^^ gets same result as ...
#>  Reading from mini-gap.
#>  Range Africa.
#>  Reading from mini-gap.
#>  Range Africa.
#> Error in gargle_abort_request_failed(error_message(resp), resp): Server error: (503) UNAVAILABLE
#>  Service unavailable. Typically the server is down.
#>  The service is currently unavailable.