Questions tagged [rstudioapi]
14 questions
6
votes
2 answers
Run selected Rmd chunks in a single command
I'm experimenting with Rmd Notebooks, and I'm stuck on something that seems like it should be possible but I cannot figure out a solution at all.
Basically, I would like a functional way to run selected Rmd chunks without compiling with knitr. So I…

plcefrmyhd
- 103
- 7
3
votes
0 answers
password in odbc connection in RShiny
In my shiny application, in global.R I have defined an odbc connection as follow :
con <- dbConnect(odbc(),
DSN = 'abc',
Database = 'xxx',
UID = rstudioapi::askForPassword("Database user"),
…

Haribo
- 2,071
- 17
- 37
3
votes
3 answers
How to run another Rscript after several R jobs running in parallel are done?
The arrangement on how I need to run my scripts is first to run the 4 R scripts in parallel using the rstudioapi::jobRunScript() function. Each of the scripts that is running in parallel does not import anything from any environment but instead…

Denelle
- 55
- 1
- 7
2
votes
2 answers
How to use indentation with `rstudioapi::insertText`
I have a string that I want to paste with indentation into RStudio using the {rstudioapi}. Here is a simple test string:
test_str <- "for (i in seq_along(x)) {\nout[[i]] <- sum(x[[i]])\n}"
cat(test_str)
#> for (i in seq_along(x)) {
#> out[[i]] <-…

TimTeaFan
- 17,549
- 4
- 18
- 39
2
votes
1 answer
How to style output in RStudio Markers tab
The help of ?rstudioapi::sourceMarkers states:
Note that if the message field is of class "html" (i.e. inherits(message, "html") == TRUE) then its contents will be treated as HTML.
However, when running the following Code, the text is evaluated as…

mnist
- 6,571
- 1
- 18
- 41
1
vote
0 answers
Test if active document in Rstudio is RMarkdown
I want to add a small function to my RStudio AddIn which extracts all chunks from an Rmarkdown document, does some transformation and displays it as new editor window in RStudio. Basically, that will be a thin wrapper around knitr::purl. The…

thothal
- 16,690
- 3
- 36
- 71
1
vote
0 answers
RStudioapi AND RMarkdown not working together
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…

Aku-Ville Lehtimäki
- 325
- 1
- 9
1
vote
1 answer
in RStudio given a package and addin name, get the function that is called
Here are some of my addins :
For example, I'd like to know programmatically what function is called by "reprex" for the addin "Reprex selection".
If I go to the repo and browse to "reprex/inst/rstudio/addins.dcf" I can see that it is…

moodymudskipper
- 46,417
- 11
- 121
- 167
0
votes
0 answers
Correct use of resourceLimits argument in rstudioapi::launcherSubmitJob
I have an issue when trying to use launcherSubmitJob with the resourceLimits argument:
rstudioapi::launcherSubmitJob(
name = "testcoresetting",
cluster = "Local",
command = "R",
args = "-e print('hi')",
resourceLimits =…

Kobus
- 1
- 1
0
votes
0 answers
rstudioapi randomly removes text when used in a snippet
I am creating a snippet that automatically takes the name of the function defined in the line below, and creates a roxygen2 documentation where the title is printed "nicely".
I have defined the following snippet:
snippet doc
`r
editor <-…

Karl
- 1,074
- 8
- 25
0
votes
0 answers
using rstudioapi in devtools tests
I'm making a package which contains a function that calls rstudioapi::jobRunScript(), and I would like to to be able to write tests for this function that can be run normally by devtools::test(). The package is only intended for use during…

lost
- 1,483
- 1
- 11
- 19
0
votes
0 answers
Set working directory to file location in R
I have a folder, say program, which contains all my scripts, data, etc:
main.R
src/
other_file_1.R
other_file_2.R
data/
some_dataset.csv
output/
stuff.txt
other_stuff.png
logs/
Readme.txt
The person who receives my folder, opens it and…

IDK
- 359
- 1
- 16
0
votes
0 answers
Rstudio Terminal Output to Object
I am using the rstudioapi package to run a command in the Rstudio terminal, like so:
myTerm <- rstudioapi::terminalCreate()
rstudioapi::terminalSend(myTerm, "echo Hello\n")
This gives me the following in the Rstudio terminal:
user@devicenum:~$ echo…

Hlachma1
- 25
- 3
0
votes
1 answer
Having trouble running Shiny app script for mini meta analysis
I'm trying to load a script from a seminar on meta analysis, which supposedly gives you an app/tool to run meta analysis. The script looks like…

Shawn Hemelstrand
- 2,676
- 4
- 17
- 30