View source: R/drake_plan_helpers.R
code_to_plan | R Documentation |
knitr
/ R Markdown report
into a drake
plan.
code_to_plan()
, plan_to_code()
, and
plan_to_notebook()
together illustrate the relationships
between drake
plans, R scripts, and R Markdown documents.
code_to_plan(path)
path |
A file path to an R script or |
This feature is easy to break, so there are some rules for your code file:
Stick to assigning a single expression to a single target at a time.
For multi-line commands, please enclose the whole command
in curly braces.
Conversely, compound assignment is not supported
(e.g. target_1 <- target_2 <- target_3 <- get_data()
).
Once you assign an expression to a variable, do not modify the variable any more. The target/command binding should be permanent.
Keep it simple. Please use the assignment operators rather than
assign()
and similar functions.
drake_plan()
, make()
, plan_to_code()
,
plan_to_notebook()
plan <- drake_plan(
raw_data = read_excel(file_in("raw_data.xlsx")),
data = raw_data,
hist = create_plot(data),
fit = lm(Ozone ~ Temp + Wind, data)
)
file <- tempfile()
# Turn the plan into an R script a the given file path.
plan_to_code(plan, file)
# Here is what the script looks like.
cat(readLines(file), sep = "\n")
# Convert back to a drake plan.
code_to_plan(file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.