Skip to contents

Walk a directory tree generated by daisy spawn, read all dlf files in it, and merge similar log files into one dlf.

Usage

read_dlf_spawn(directory, pattern = ".*\\.dlf", col_name = "sim")

Arguments

directory

Path to directory

pattern

Regex pattern of files to include

col_name

Name of column to store directory name in

Value

A list of S4 objects of class Dlf. Each dlf is named with the log type and the directory is stored in the column col_name

Examples

data_dir <- file.path(system.file("extdata", package="daisyrVis",
                                  "daisy-spawn-like"))
print(list.files(data_dir, recursive=TRUE))
#>  [1] "Pig_JB1_Free/FWater200-Y.dlf"   "Pig_JB1_Free/Harvest.dlf"      
#>  [3] "Pig_JB6_Free/FWater200-Y.dlf"   "Pig_JB6_Free/Harvest.dlf"      
#>  [5] "Pig_JB6_Pipe/FWater200-Y.dlf"   "Pig_JB6_Pipe/Harvest.dlf"      
#>  [7] "Plant_JB1_Free/FWater200-Y.dlf" "Plant_JB1_Free/Harvest.dlf"    
#>  [9] "Plant_JB6_Free/FWater200-Y.dlf" "Plant_JB6_Free/Harvest.dlf"    
#> [11] "Plant_JB6_Pipe/FWater200-Y.dlf" "Plant_JB6_Pipe/Harvest.dlf"    
dlfs <- read_dlf_spawn(data_dir)
dlf_names <- names(dlfs)
print(dlf_names)
#> [1] "FWater200-Y" "Harvest"    

print(unique(dlfs[[dlf_names[1]]]$sim))
#> [1] "Pig_JB1_Free"   "Pig_JB6_Free"   "Pig_JB6_Pipe"   "Plant_JB1_Free"
#> [5] "Plant_JB6_Free" "Plant_JB6_Pipe"