library("tidyverse")
library("googlesheets4") 
library("googledrive")
gdp2021.df <- read_csv("./2021gdp_by_region.csv")

drive_auth(email = "gwet62@gmail.com")
gss.uspop <- drive_get(path="us-population-statistics") 

#- Write 2021 GDP data to the "Gross Domestic Product" sheet
gs4_auth(email = "gwet62@gmail.com")
read_sheet(ss=gss.uspop,sheet="Gross Domestic Product")
range_write(ss = gss.uspop, data = gdp2021.df, 
            sheet = "Gross Domestic Product", 
            range = "G1", col_names = TRUE)
gs4_browse(ss=gss.uspop)

#- Clear the specific range of cells "G1:J11" --- 
range_write(ss = gss.uspop, data = tibble(), 
            sheet = "Gross Domestic Product", 
            range = "G1:J11")

#-- Delete 
sheet_delete(ss=gss, sheet="Gross Domestic Product")

#-- Delete a Google spreadsheet and move it to the trash
gs4_find("Gross Domestic Product") %>%
  drive_trash()
