I'm trying to publish a Shiny app to shinyapps.io but the app requires a Quandl API connection. I don't want to put the API key in my code so I use a .Renviron file to store the API key.
This is the content of the .Renviron file:
QUANDL_API_KEY=api_key_goes_here
This is the content of the .Rmd file:
---
title: "Test"
runtime: shiny
output: html_document
---
```{r}
print(Sys.getenv("QUANDL_API_KEY"))
```
When I deploy to shinyapps.io nothing is printed out. But when I run locally, the key is printed. The .Renviron file is in the app root directory.
What am I doing wrong?
As Bill Ash suggests in the comments, using readRenviron() at the beginning of the script worked for me:
---
title: "Test"
runtime: shiny
output: html_document
---
```{r}
readRenviron(".Renviron")
print(Sys.getenv("QUANDL_API_KEY"))
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With