Learn R Programming

workflowr (version 0.2.0)

open_rmd: Open an R Markdown analysis file

Description

open_rmd opens an R Markdown file in RStudio and sets the working directory to analysis/. If the file does not exist, it creates a new Rmd using the workflowr template.

Usage

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

Arguments

filename

The basename of the R Markdown file.

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.

Details

open_rmd is a convenience function to make it easier to start working, especially when starting a new analysis. It will create the new file if necessary, set the working directory to analysis/, and open the file 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 use 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 {
open_rmd("model-data.Rmd")
# }

Run the code above in your browser using DataLab