I have a drake plan which uses a input folder with file_in
. Then reads each file inside the folder and makes a number of transformations. Finally, it joins the results.
If I add a new file, I would like that the new calculations in plan are only applied to this file, and then joined to the previous results. However, what the plan does is: it detects a change in target, then recalculates all targets based on that target.
Note: The number of files is quite large (several thousands), and calculations heavy.
Solution (look at landau's solution for a better solution)
This solution completes the answer I marked as solution:
Any file or directory you declare with file_in() or target(format = "file") is treated as an irreducible unit of data, and this behavior in drake will not change in future development. But you can split up the files among multiple targets so some targets stay up to date if a file changes.
library(drake)
drake_plan(
input = target(list.files(file_in("/path/to/folder")),format="file"),
target1 = target(do_stuff1(input), dynamic=map(input))
)
This will make dynamic targets, and therefore the new files will create new dynamic targets, but the old target will not be re-calculated.