R Download Rstudioapi [TOP]

0 views
Skip to first unread message

Aline Lanosga

unread,
Jan 21, 2024, 3:15:36 AM1/21/24
to petlochewhin

The rstudioapi package is designed to make it easy to conditionally access the RStudio API from CRAN packages, avoiding any potential problems with R CMD check. This package contains a handful of useful wrapper functions to access the API. To see the functions that are currently available in the API, run help(package = "rstudioapi")

Great, thanks!
At the meantime I'll probably use the ugly workaround of running a shell script to capture and kill the process running the job.
I know . but it works.
Everything else w.r.t. job management can be done via the rstudioapi.
Not sure whether I would still be able to use the feature of passing in an environment to store newly created object as it may not survive the violent kill, but I can do without it, my job barely creates any global variables.

r download rstudioapi


Download File ✺✺✺ https://t.co/xKpNE1Vq26



Related question:
Is there is an easy way to use the job id that I get from the rstudioapi to identify (from the unix command line) the process that runs that job based on the (numerical) job id that is returned by rstudioapi::jobRunScript call?
I can easily do without it, as the command line process description has the name of the script file embedded in it, but being able to confirm that using the job id should be good for a sanity check when running an ugly workaround.
Thanks!

Is there is an easy way to use the job id that I get from the rstudioapi to identify (from the unix command line) the process that runs that job based on the (numerical) job id that is returned by rstudioapi::jobRunScript call?

Proposals: I think that the most intuitive way for the users would be a rstudioapi::getProcessID function, or at least return the process ID from the jobRunScript call, together with the job id via a list / structure. E.g.

Ideally, I'd like to use no other package than the rstudioapi or base R. Looking at the documentation insertText also has a location argument which works with positions or ranges in scripts. I'm not sure whether this can be somehow used to include indentation.

I'm also looking at the datapasta package which also uses the rstudioapi and here the "num_spaces_for_tab"option is used in the output_context (in the script called oc$nspc), but I'm not sure how to apply it to my problem.

The rstudioapi package is designed to make it easy to conditionally access the Rstudio API from CRAN packages, avoiding any potential problems with R CMD check. This package contains a handful of useful wrapper functions to access the API. To see the functions that are currently available in the API, run help(package = "rstudio")

Current script relies on rstudioapi and clipr packages. Presumably in electron version new packages will be provided. One of us here should (and RStudio enthusiasts can) look into what APIs are being developed / ported to electron.

The key idea is to use the function rstudioapi::insertText() to insert text in the RStudio source editor, and the editor context can be obtained from rstudioapi::getSourceEditorContext(). The rest of things to do is a plain for loop, in which you insert characters one by one, and use Sys.sleep() to pause occasionally (and randomly), otherwise it will be obviously bogus.

This becomes an issue with rstudioapi::jobRunScript because this "job environment" is in the background. While it can export an environment, this only happens at the end of the job, and rmarkdown_1.rmd needs it during the job.

For addins in particular, a number of methods were added that allow R code to introspect and mutate the contents of a document open in RStudio. These methods are outlined below briefly, but see documentation within the rstudioapi package for more details.

Creating addins with Shiny Gadgets requires shiny, miniUI, and rstudioapi packages from CRAN. To create an addin package, add these packages to the package DESCRIPTION file as follows:

In case you want to automatize the definition of your working directory, it makes a lot of sense to set the working directory to source file location with some R programming code. For this task, we first need to load the rstudioapi package:

df19127ead
Reply all
Reply to author
Forward
0 new messages