wflow_open | R Documentation |
wflow_open
opens R Markdown files in RStudio and sets the working
directory to the knit directory (see Details). If a file does not exist, a
minimal one is created.
wflow_open(files, change_wd = TRUE, edit_in_rstudio = TRUE, project = ".")
files |
character. R Markdown file(s) to open. Files must have the
extension Rmd or rmd. Supports file
globbing. Set
|
change_wd |
logical (default: TRUE). Change the working directory to the
knit directory. If |
edit_in_rstudio |
logical (default: TRUE). Open the file(s) in the RStudio editor. |
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 |
wflow_open
is a convenience function to make it easier to begin
working, especially when starting a new analysis. First, it creates a new
file if necessary and tries to make educated guesses about metadata like the
title, author, and date. Second, it sets the working directory to the knit
directory. The knit directory is where the code in the R Markdown files is
executed, and may be defined via the field knit_root_dir
in the file
_workflowr.yml
(see wflow_html
for all the details). If
this field is not defined, then the knit directory is the R Markdown
directory. Third, it opens the file(s) in RStudio if applicable. The latter
two side effects can be turned off if desired.
If you would like to create an R Markdown file with wflow_open
for an
analysis that is not part of a workflowr project, set project = NULL
.
Otherwise wflow_open
will throw an error. Note that the working
directory is not changed when project = NULL
.
An object of class wflow_open
, which is a list with the
following elements:
files |
The input argument |
change_wd |
The input argument |
edit_in_rstudio |
The input argument |
knit_root_dir |
The knit directory (see |
previous_wd |
The working directory in which |
new_wd |
The working directory that |
files_new |
The subset of the input argument |
## Not run:
wflow_open("analysis/model-data.Rmd")
# Multiple files
wflow_open(c("analysis/model-data.Rmd", "analysis/another-analysis.Rmd"))
# Open all R Markdown files
wflow_open("analysis/*Rmd")
# Create an R Markdown file in a non-worklowr project
wflow_open("model-data.Rmd", project = NULL)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.