Learn R Programming

workflowr (version 0.3.0)

wflow_open: Open R Markdown analysis file(s)

Description

wflow_open opens R Markdown files in RStudio and sets the working directory to analysis/. If a file does not exist, it is created using the workflowr R Markdown template.

Usage

wflow_open(filename, change_wd = TRUE, open_file = TRUE, path = ".")

Arguments

filename

The name of the R Markdown file(s) (can be either a path or just the basename, but will always be written to analysis/ directory). File extension must be .Rmd.

change_wd

Should the working directory be changed to the analysis subdirectory? (default: TRUE)

open_file

Should the file be opened in RStudio editor? (default: TRUE)

path

By default the function assumes the current working directory is within the project. If this is not true, you'll need to provide the path to the project directory.

Value

Invisibly returns the full path to the R Markdown file(s).

Details

wflow_open is a convenience function to make it easier to start working, especially when starting a new analysis. It will create a new file if necessary, set the working directory to analysis/, and open the file(s) in RStudio. The latter two side effects can be turned off if desired.

If you are not using RStudio and are comfortable with relative paths and managing your working directory, you could instead directly use the underlying commands. First set the working directory to the analysis/ subdirectory of your workflowr project. Second create the new file with draft("model-data.Rmd", template = "analysis", package = "workflowr", edit = FALSE). Third open the file in your text editor.

Examples

Run this code
# NOT RUN {
# Any of the following are valid input. Files would be created if they did
# not exist.
# Basename of file:
wflow_open("model-data.Rmd")
# Path to file
wflow_open("analysis/model-data.Rmd")
# Multiple files
wflow_open(c("model-data.Rmd", "another-analysis.Rmd"))
# }

Run the code above in your browser using DataLab