I am attempting to knit a .Rmd file that uses googlesheets4, but the execution fails every time. Here's my code where it fails:
for (package in c('tidyverse', 'googledrive', 'googlesheets4')) {
if (!require(package, character.only=T, quietly=T)) {
install.packages(package)
library(package, character.only=T)
}
}
data <- read_sheet("mysheetidgoeshere")
When trying to knit the Rmd with this code, it fails on this section and gives this error:
Error: Can't get Google credentials.
Are you running googlesheets4 in a non-interactive session? Consider:
* `gs4_deauth()` to prevent the attempt to get credentials.
* Call `gs4_auth()` directly with all necessary specifics.
See gargle's "Non-interactive auth" vignette for more details:
https://gargle.r-lib.org/articles/non-interactive-auth.html
Execution halted
The thing is, this code works perfectly when ran normally but only fails when trying to knit. I've tried authenticating the session multiple ways but none seem to work.
Using R version 3.5.1, Mac OS X 10.13.6
Edit
I was able to knit the Rmd using
rmarkdown::render("nameoffile.Rmd")
Not sure why the "Knit" button in the Rmarkdown didn't work, but at least the file is knit now.