pacman::p_load(dplyr, ggplot2, googlesheets, openxlsx)
Prepare the OAuth token and set up the target sheet.
shiny_token <- gs_auth() #saveRDS(shiny_token, "shiny_app_lol_token.rds")
Into the App...
# googlesheets::gs_auth(token = "shiny_app_lol_token.rds") # sheet_key <- "1qIPAnsvFh23IZJl-5tfYPc1SnYrbApJ82sXfA4acuaw" # ss <- googlesheets::gs_key(sheet_key)
If you have a big dataframe use gs_upload_big
. Speed up big data uploads by csv upload...
gs_upload_big <- function(tbl, data){ # speed up big data uploads by csv upload file_name <- paste0(tbl, ".xlsx") openxlsx::write.xlsx(data, file = file_name) googlesheets::gs_upload( file = file_name, sheet_title = tbl ) file.remove(file_name) } gs_upload_big("mtcars1", mtcars)
If you only want to initialize a data sheat with some entries use gs_upload
gs_upload <- function(tbl, data){ out <- gs_new( tbl, input = data, trim = T ) return(out) } gs_upload("mtcars2", mtcars)
id <- gs_title("mtcars") sheet_key <- id$sheet_key #id %>% gs_browse() mtcars <- id %>% gs_read()
gs_append_row <- function(tbl, row){ tbl %>% gs_add_row(input = row) } gs_append_row(id, mtcars[1,])
gs_append_rows <- function(tbl, data){ data %>% split(1:nrow(.)) %>% purrr::walk(~gs_append_row(tbl, .x)) } gs_append_rows(id, mtcars[1:5,]) #id <- gs_title("no_label") #id %>% gs_browse() #no_label <- gs_read(id)
## authentification googlesheets::gs_auth(token = "google_paraboost_token.rds") sheet_key <- "1ZTifdHQe5Tg96-MAwj4Xs2UuonNYSFHwHgn-gfgnBIo" with_label <- googlesheets::gs_key(sheet_key)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.