script.new: Open new R Script, R Markdown script, or SQL Script in...

View source: R/script.new.R

script.newR Documentation

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.

Details

The function documentNew() in the package rstudioapi is used to open an R script.

Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at

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

See Also

script.close, script.open, script.save, setsource

Examples

## Not run: 

# Open new R script file
script.new()

# Open new R script file and run some code
script.new("#----------------------------
# Example

# Generate 100 random numbers
rnorm(100)")

## End(Not run)

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to script.new in misty...