prScript: create and/or open R scripts

Description Usage Arguments Details See Also Examples

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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")

FrancoisGuillem/project documentation built on May 6, 2019, 5:06 p.m.