I have the API credentials in one separate R script to keep it out of Git. I want to run this script in the beginning of the scripts that actually interact with the different servers. I have successfully used the same strategy for all my global functions.
setwd("G:/script")
source("API_credentials.R") # gives always an error
# > source("API_credentials.R")
# Error: '\s' is an unrecognized escape in character string starting ""g:\s"
source("ProVeg_functions.R") # runs fine
Problem:
Why does the first source() not work, while the second one does? The error message does not make any sense to me.
Solutions tried:
- I have tried different escape chars \.
- I have tried writing full path & file names.
- I have tried putting the file name in as a variable, which gets its content from a dir() search, to make sure that the file exists and the name is correctly written.
- Order of source() does not change situation.
- Isolating the piece of code with error, and restarting R.
- upgraded all my packages and R to version 4.0.2.
- The API_credentials.r script works fine when run on its own. the Sys.setenv() works fine and I can read the API keys with Sys.getenv().
- I am not sure if it is related to my problem, but if I do usethis::edit_r_environ() I can not see my API keys.
Setup Windows 10, R-Studio 1.3.1093, R version 4.0.2 (2020-06-22)