Skip to content

Instantly share code, notes, and snippets.

@saudiwin
Last active September 26, 2025 15:04
Show Gist options
  • Select an option

  • Save saudiwin/9863c79fdd91a7888adb02720ed00855 to your computer and use it in GitHub Desktop.

Select an option

Save saudiwin/9863c79fdd91a7888adb02720ed00855 to your computer and use it in GitHub Desktop.
Automate the creation of google documents for class
# generate google drive files for class
library(googledrive)
library(readr)
library(readxl)
library(tidyverse)
library(stringr)
# need class roster/blackboard export
class_list <- read_csv("data/cp_dev_fall_2025.csv")
# name of folder to save files in Google Drive (note: you will need to first authenticate with googledrive::drive_auth()
folder_path <- "class_dev_fall_2025"
em <- paste0("Hi, ",class_list$`First Name`[1],
", see the attached Google Doc that you can use for your policy memo. We'll talk more about it on Thursday. -Bob Kubinec")
# wrap it in a loop for the people in class
lapply(1:nrow(class_list), function(i) {
drive_create(name=str_squish(class_list$`Last Name`[i]),
path=folder_path,
type="document")
em <- paste0("Hi, ",class_list$`First Name`[i],
", see the attached Google Doc that you can use for your policy memo. We'll talk more about it on Thursday. -Bob Kubinec")
try(drive_share(paste0(folder_path,"/",class_list$`Last Name`[i]),
role = "writer",
type="user",
emailMessage=em,
emailAddress=paste0(class_list$Username[i],"@email.sc.edu")))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment