script.new: Open new R Script, R Markdown script, or SQL Script in RStudio
Description
This function is used to open a new R script, R markdown script, or SQL script
in RStudio.
Usage
script.new(text = "", type = c("r", "rmarkdown", "sql"),
position = rstudioapi::document_position(0, 0),
run = FALSE, check = TRUE)
Arguments
text
a character vector indicating what text should be inserted in
the new R script. By default, an empty script is opened.
type
a character string indicating the type of document to be
created, i.e., r (default) for an R script, rmakrdown
for an R Markdown file, or sql for an SQL script.
position
document_position() function in the rstudioapi
package indicating the cursor position.
run
logical: if TRUE, the code is executed after the document
is created.
check
logical: if TRUE, argument specification is checked.
The function documentNew() in the package rstudioapi is used to
open an R script.
References
Ushey, K., Allaire, J., Wickham, H., & Ritchie, G. (2022). rstudioapi: Safely
access the RStudio API. R package version 0.14.
https://CRAN.R-project.org/package=rstudioapi
if (FALSE) {
# Open new R script filescript.new()
# Open new R script file and run some codescript.new("#----------------------------
# Example
# Generate 100 random numbers
rnorm(100)")
}