DillonHammill / DataEditR

An Interactive R Package for Viewing, Entering Filtering and Editing Data
https://dillonhammill.github.io/DataEditR/
384 stars 40 forks source link

Writing to googlesheets #26

Closed RoshanPShetty closed 3 years ago

RoshanPShetty commented 3 years ago

Hi @DillonHammill Thank you for creating this wonderful package! I wanted to know if it was possible to write and save the data from the shiny app to googlesheets instead of having to save it on our local storage.

DillonHammill commented 3 years ago

@RoshanPShetty thanks for bringing this up. After playing around with this a bit, it turns out that we cannot write to googlesheets after closing the data editor - instead we have to write to file before the app closes. I have made this change to the development version of DataEditR (v0.1.4) on GitHub.

devtools::install_github("DillonHammill/DataEditR")

library(DataEditR)
library(googlesheets4)

# Authorise googlesheets
gs4_auth(
  email = "username@gmail.com"
)

# Create new sheet
ss <- gs4_create(
  "test"
)
# Edit data and write to new sheet called mtcars
mtcars_new <- data_edit(
  mtcars,
  save_as = ss,
  write_fun = "write_sheet",
  write_args = list(sheet = "mtcars")
)