-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use tibbles and language objects internally instead of data frames and text #247
Comments
Language objects can be modified like this:
Why? |
Thanks, @clarkfitzg! Knowing this helps a ton. I heard somewhere that |
List columns work with ordinary data frames.
|
We do have |
I think we can start with accepting a plan data frame that has a list column full of calls in the |
Actually, depending on whether we use quosures, there may not even be anything to change in the internals. library(drake)
plan <- data.frame(target = letters[1:2])
plan$command <- list(quote(sqrt(1 + 1234123)), quote(c("x", "y")))
plan
#> target command
#> 1 a sqrt(1 + 1234123)
#> 2 b c("x", "y")
make(plan)
#> cache /tmp/RtmpmonKp5/.drake
#> connect 1 import: plan
#> connect 2 targets: a, b
#> check 2 items: c, sqrt
#> check 2 items: a, b
#> All targets are already up to date.
make(plan)
#> cache /tmp/RtmpmonKp5/.drake
#> connect 1 import: plan
#> connect 2 targets: a, b
#> check 2 items: c, sqrt
#> check 2 items: a, b
#> All targets are already up to date.
plan$command = c("sqrt(1 + 1234123)", "c(\"x\", \"y\")")
make(plan)
#> cache /tmp/RtmpmonKp5/.drake
#> connect 1 import: plan
#> connect 2 targets: a, b
#> check 2 items: c, sqrt
#> check 2 items: a, b
#> All targets are already up to date. So language objects may be fine. |
Can we change |
Quite possibly, but printing may not be as nice. library(drake)
my_plan <- drake_plan(x = simulate(), y = summarize(x))
my_plan
#> # A tibble: 2 x 2
#> target command
#> <chr> <chr>
#> 1 x simulate()
#> 2 y summarize(x)
my_plan$command <- as.list(my_plan$command)
my_plan
#> # A tibble: 2 x 2
#> target command
#> <chr> <list>
#> 1 x <chr [1]>
#> 2 y <chr [1]> |
Fortunately, that's easy to fix ;-) |
Maybe even with an S3 class that prints with syntax highlighting? |
That would be super nice. +1 if it also works in HTML vignettes. |
We can do it with some tweaking, see tidyverse/tidyverse.org#121 and https://www.tidyverse.org/articles/2018/03/pillar-1-2-1/. |
...now that pillar 1.2.1 is out. Rleated: #247.
Update from R/Pharma 2018: if we do ever make a complete switch from text to language objects, |
I still prefer users to be able to supply data frames of text, but I think the preferable format of a workflow plan should be a tibble with commands as language objects or something similar. @krlmlr, I think we agree on this. To me, it seems like the more natural, more sophisticated, and safer way of doing things.
When I began
drake
, I knew almost nothing about computing on the language, and I was much more comfortable with text processing. I am still not an expert in computing on the language, so I think I will need help to get this right. #246 is a first step, and it frees up work on other issues, but there is a lot more to do.From my perspective, there are some challenges:
local({...})
. Currently, it is perfectly fine to writeplan <- drake_plan(target = {x <- 1; x})
, andmake(plan)
does not add or modifyx
in the user's environment. We should keep this behavior in order to avoid side effects and race conditions. So far, I have been adding onlocal({...})
withpaste0()
in preprocess_command(), and I hope there is a similar way to modify language objects.drake
should even use quosures internally instead of ordinary language objects. We should make a solid group decision on this.The text was updated successfully, but these errors were encountered: