prScript {tinyProject}R Documentation

create and/or open R scripts

Description

prScript creates and opens a new script for edition. If the script already exists, it opens it in the Rstudio editor.

Usage

prScript(name, template, subdir = ".", instructions = TRUE)

Arguments

name

(optional) name of the script to create and/or open. This parameter can also include the subfolder where to save the script (see examples).

template

(Optional) One of "analysis", "data" or "function". Template to use for the creation of a script. prScript adds a few comments that encourage the user to add comments and explain what the script will do. These comments depend on the choosen template. If the argument is missing, the choosen template depends on the name of the script: "data" if the name begins with "data", "function" if it start with "tools" and "analysis" in all other cases.

subdir

subdirectory where the scripts needs to be created or opened. The subdirectory can also be directly specified in the parameter name.

instructions

Should the created script include some instructions?

Details

If the parameter name is missing, then a list of existing scripts is displayed. The user is then invited to choose one by typing the number or name of the script he wants to open.

See Also

prSource, prMoveScript, prRenameScript, prDeleteScript

Examples

projectPath <- file.path(tempdir(), "test")
prInit(projectPath)

prScript("test")
list.files(projectPath, recursive = TRUE, include.dirs = TRUE)

prScript("myFunction", template = "function")

# Create script in a subfolder
prScript("test", subdir = "testdir")

# Or equivalently
prScript("testdir/test")


[Package tinyProject version 0.6.1 Index]