I am building an application in RMarkdown that relies upon a user-generated password:
library(getPass)
pw <- getPass(msg = "Enter the Password, please!")
When I run all of the code interactively in the R console, the getPass function pauses the code and provides a popup window in which a user can enter the password.
However, when including this code in RMarkdown, the knitting process does not halt for getPass to do its work. As a result, the code runs without the password. In this case, it prevents the application from connecting to the password-protected database.
Do any of you have a recommendation for how to resolve this issue? I have searched for similar questions, but if this is a duplicate, then my apologies. Thank you!
As stated in comment use parameterized report.
Your rmarkdown should look like:
---
output: html_document
params:
pwd:
label: "Enter the Password, please!"
value: ""
input: password
---
Your password is `r params$pwd`
Now either run
rmarkdown::render("test.Rmd", params="ask")
or use RStudio button "Knitr with parameters":
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