Convenience write function for generating targets files containing the paths to files generated by input processes. These processes can be commandline- or R-based software. Typically, the paths to the inputs are stored in the targets infile targetsWF(sysargs) for SYSargsList objects. Note: by default the function cannot overwrite any existing files. If a file exists then the user has to explicitly remove it or set overwrite=TRUE.

writeTargets(sysargs, step, file = "default", silent = FALSE, overwrite = FALSE)

Arguments

sysargs

Object of class SYSargsList.

step

character with the step name. To check all the names, please use stepName(sysargs).

file

Name and path of the output file. If set to "default" then the name of the output file will have the pattern 'targets_<stepName>.txt'.

silent

If set to TRUE, all messages returned by the function will be suppressed.

overwrite

If set to TRUE, existing files of same name will be overwritten.

Value

Writes tabular targes files containing the header/comment lines from

stepsWF(sysargs)[[step]][["targetsheader"]] and the columns from targetsWF(sysargs)[[step]].

Author

Daniela Cassol

Examples

## Construct SYSargsList object from Rmd file
sal <- SPRproject(overwrite=TRUE)
#> Recreating directory '/home/runner/work/systemPipeR/systemPipeR/docs/reference/.SPRproject'
#> Creating file '/home/runner/work/systemPipeR/systemPipeR/docs/reference/.SPRproject/SYSargsList.yml'
targetspath <- system.file("extdata/cwl/example/targets_example.txt", package="systemPipeR")

## Constructor and `appendStep<-`
appendStep(sal) <- SYSargsList(step_name = "echo", 
                               targets=targetspath, dir=TRUE,
                               wf_file="example/workflow_example.cwl", input_file="example/example.yml", 
                               dir_path = system.file("extdata/cwl", package="systemPipeR"),
                               inputvars = c(Message = "_STRING_", SampleName = "_SAMPLE_"))
appendStep(sal) <- LineWise(code = {
                            hello <- lapply(getColumn(sal, step=1, 'outfiles'), function(x) yaml::read_yaml(x))
                            }, 
                            step_name = "R_read", 
                            dependency = "echo")
writeTargets(sal, "echo")
#> 	 Written content of 'targetsout(x)' to file: targets_echo.txt