From 96ac2fd949079b1fae2af279ef53b680bc6c0cbf Mon Sep 17 00:00:00 2001 From: Collin Schwantes Date: Tue, 18 Jun 2024 09:08:51 -0600 Subject: [PATCH] fixed copy paste error in single sheet read --- R/read_googlesheets.R | 4 ++-- man/read_googlesheets.Rd | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/R/read_googlesheets.R b/R/read_googlesheets.R index bf37d1f..b902ea5 100644 --- a/R/read_googlesheets.R +++ b/R/read_googlesheets.R @@ -34,7 +34,7 @@ read_googlesheets <- sheet_names <- rlang::set_names(sheet_names, sheet_names) dat <- purrr::map(sheet_names, - \(x){ + function(x){ df <- googlesheets4::range_read( ss = ss, sheet = x, @@ -63,7 +63,7 @@ read_googlesheets <- if(add_primary_key_field){ #ss_sheet_rownum - row_ids <- paste(ss,x,1:nrow(dat),sep = "_") + row_ids <- paste(ss,sheet,1:nrow(dat),sep = "_") dat <- dat %>% dplyr::mutate({{primary_key}} := {{row_ids}}) diff --git a/man/read_googlesheets.Rd b/man/read_googlesheets.Rd index d5e3e63..81f57a6 100644 --- a/man/read_googlesheets.Rd +++ b/man/read_googlesheets.Rd @@ -4,7 +4,14 @@ \alias{read_googlesheets} \title{Read Google Sheets Data} \usage{ -read_googlesheets(key_path, sheet = "all", ss, ...) +read_googlesheets( + key_path, + sheet = "all", + ss, + add_primary_key_field = FALSE, + primary_key = "primary_key", + ... +) } \arguments{ \item{key_path}{character path to Google authentication key json file} @@ -13,6 +20,10 @@ read_googlesheets(key_path, sheet = "all", ss, ...) \item{ss}{Something that identifies a Google Sheet such as drive id or URL} +\item{add_primary_key_field}{Logical. Should a primary key field be added?} + +\item{primary_key}{character. The column name for the unique identifier to be added to the data.} + \item{...}{other arguments passed to `googlesheets4::range_read()`} } \value{ @@ -23,7 +34,7 @@ For a given sheet id, this handles authentication and reads in a specified sheet } \examples{ \dontrun{ -read_googlesheets(ss = kzn_animal_ship_sheets, sheet = "all") +read_googlesheets(ss = kzn_animal_ship_sheets, sheet = "all",) } }