wflow_open
opens R Markdown files in RStudio and sets the working
directory to the analysis directory. If a file does not exist, it is created
using the workflowr R Markdown template.
wflow_open(files, change_wd = TRUE, open_file = TRUE, standalone = FALSE, project = ".")
files | character. The name of the R Markdown file(s). If |
---|---|
change_wd | logical (default: TRUE). Change the working directory to the
analysis directory. If |
open_file | logical (default: TRUE). Open the file in the RStudio editor. |
standalone | logical (default: FALSE). Embed the configuration chunks directly in the document to create a standalone file. Should only need to be used when creating files outside the context of a workflowr project. |
project | character (or NULL). 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. Set |
Invisibly returns the relative path(s) to the R Markdown file(s).
wflow_open
is a convenience function to make it easier to begin
working, especially when starting a new analysis. It will create a new file
if necessary using the workflowr template, set the working directory to
the analysis directory, and open the file(s) in RStudio. The latter two side
effects can be turned off if desired.
If you would like to create a file using the workflowr template for an
analysis that is not part of a workflowr project, set standalone =
TRUE
to directly embed the shared configuration chunks into the document and
set project = NULL
to prevent wflow_open
from searching for an
analysis directory.
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
directory 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.
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")) # Use the workflowr template in a non-worklowr project wflow_open("model-data.Rmd", standalone = TRUE, project = NULL) })