Dambo
Dambo

Reputation: 3496

How to assign a string to an object in drake?

I am trying to "parameterize" a drake script by assign a character to an object but I get this warning:

plan <- drake_plan(commencement = "dec2017")
make(plan)
Warning messages:

1: missing input files: dec2017
2: File 'dec2017' was built or processed, but the file itself does not exist

Everything works fine if I loadd('commencement') but I am not what's the non-existant file that is being created. That creates issues later on in the script because commencement is embedded in files path.

Upvotes: 0

Views: 60

Answers (2)

C. Hammill
C. Hammill

Reputation: 342

This is a known issue which is going to be fixed in newer versions of drake.

All you need to do to get your code to work is to run:

pkgconfig::set_config("drake::strings_in_dots" = "literals")

before drake_plan. This tells drake to treat strings as strings, instead of filenames. Alternatively you can pass the argument strings_as_dots = "literals" directly to drake_plan.

File inputs and outputs need to be specified manually in this mode with file_in and file_out.

Upvotes: 0

David
David

Reputation: 10222

As far as I understand drake, you mostly deal with functions. One workaround would be this

foo <- function() "dec2017"
plan <- drake_plan(commencement = foo())
make(plan)
#> target commencement

Upvotes: 1

Related Questions