R/gsheets.r

Defines functions gsheet_send gsheet_send_linux

Documented in gsheet_send gsheet_send_linux

#' Takes a table and updates a google sheet with the information in it
#' Uses tempdir to create a temporary file, since there seems to be know way of passing dataframes directly to gdrive
#' @export


gsheet_send <- function(table,g_file, na_handle) {

  tmp <- paste(tempdir(),g_file,sep="\\")
  write.csv(table
            ,file = tmp
            ,na = na_handle)
  gfile <- googledrive::drive_get(g_file)
  googledrive::drive_update(gfile
               ,tmp
                ,name = g_file)


}

#' Linux version of pervious command
#' @export

gsheet_send_linux <- function(table,g_file, na_handle) {
  tmp <- paste(tempdir(),g_file,sep="/")
  write.csv(table
            ,file = tmp
            ,na = na_handle)
  gfile <- googledrive::drive_get(g_file)
  googledrive::drive_update(gfile
                            ,tmp
                            ,name = g_file)
}
rwebsterav/rarsons documentation built on Dec. 31, 2019, 9:28 a.m.