
Last chance! 50% off unlimited learning
Sale ends in
drake
workflow plan data frame.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)
A file path to an R script or knitr
report.
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.
# NOT RUN {
plan <- drake_plan(
raw_data = read_excel(file_in("raw_data.xlsx")),
data = raw_data,
hist = create_plot(data),
fit = lm(Sepal.Width ~ Petal.Width + Species, 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)
# }
Run the code above in your browser using DataLab