The functions you are trying to run are intended for use in an interactive RStudio session.
The function rstudioapi::isAvailable()
will report if RStudio is running and can be used to conditionally execute code.
If you put rstudioapi::isAvailable()
in an Rmd chunk and knit/render it, you will see the return value is FALSE
.
What is your actual goal?