script.open {misty} | R Documentation |
Open, Close and Save R Script in RStudio
Description
The function script.open
opens an R script, R markdown script, or SQL
script in RStudio, the function script.close
closes an R script, and
the function script.save
saves an R script. Note that the R script need
to have a file location before the script can be saved.
Usage
script.open(path, line = 1, col = 1, cursor = TRUE, run = FALSE,
echo = TRUE, max.length = 999, spaced = TRUE, check = TRUE)
script.close(save = FALSE, check = TRUE)
script.save(all = FALSE, check = TRUE)
Arguments
path |
a character string indicating the path of the script. |
line |
a numeric value indicating the line in the script to navigate to. |
col |
a numeric value indicating the column in the script to navigate to. |
cursor |
logical: if |
run |
logical: if |
echo |
logical: if |
max.length |
a numeric value indicating the maximal number of characters output for the deparse of a single expression. |
spaced |
logical: if |
save |
logical: if |
all |
logical: if |
check |
logical: if |
Note
This function uses the documentOpen()
, documentPath()
,
documentClose()
, documentSave()
, and documentSaveAll()
functions in the rstudioapi package by Kevin Ushey, JJ Allaire, Hadley
Wickham, and Gary Ritchie (2023).
Author(s)
Takuya Yanagida takuya.yanagida@univie.ac.at
References
Ushey, K., Allaire, J., Wickham, H., & Ritchie, G. (2023). rstudioapi: Safely access the RStudio API. R package version 0.15.0 https://CRAN.R-project.org/package=rstudioapi
See Also
script.save
, script.copy
, setsource
Examples
## Not run:
# Example 1: Open R script file
script.open("script.R")
# Example 2: Open R script file and run the code
script.open("script.R", run = TRUE)
# Example 3: Close current R script file
script.close()
# Example 4: Save current R script
script.save()
# Example 5: Save all R scripts
script.save(all = TRUE)
## End(Not run)