Just as a note, since reprex uses rmarkdown/knitr to run your code in a separate, non-interactive R session, functions from rstudioapi are not going to work (as far as the reprex session is concerned, RStudio is not running). This is one of the few situations where unfortunately, using reprex creates confusion rather than clarity!