RStudioapi AND RMarkdown not working together

178 views Asked by At

The following code runs nicely in the console or from an .r-file:

library(rstudioapi)
thisisthepathvariable <- rstudioapi::selectDirectory(caption = "Select path")

A dialog box opens, where I can select a path, this path is saved to the variable thisisthepathvariable in string format, as it should.

However, I would like to implement the same functionality in an RMarkdown document, but when I press the green play button on top right...

selectDirectory in RMarkdown

...the green play button turns into a clock, and when I click the clock icon, I get:

The code in this chunk is scheduled to run later, when other chunks have finished executing

If I click OK, the dialog disappears, but the clock is still there and if I click don't run the running stops and the clock turns back into that green play button.

So why isn't this working? Is there a way to use rstudioapi dialogs from RMarkdown documents? Am I doing something wrong?

0

There are 0 answers