Skip to contents

File path handler

Usage

expand_Rscript(fps, debug = F)

Arguments

fps

A character vector of paths. The vector can be a mix of either (1) directory paths, (2) file paths, or (3) glob expressions to R scripts. Note that (2) and (3) must end with .R or .r. See expand_Rscript() for details.

debug

Logical. Whether to return results as a list with fps as names.

Value

A character vector or a list.

Examples

expand_Rscript = fundoc:::expand_Rscript
dir_ = system.file(package = "fundoc")
(a_file = file.path(dir_, "foo.R"))
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/foo.R"
expand_Rscript(a_file)
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/foo.R"
(a_dir = file.path(dir_, "R"))
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/R"
expand_Rscript(a_dir)
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/R/a.R"
(a_glob = file.path(dir_, "*", "*.R"))
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/*/*.R"
expand_Rscript(a_glob)
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/R/a.R"
# Mix file paths
expand_Rscript( c(a_file, a_dir, a_glob) )
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/foo.R"
#> [2] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/R/a.R"
expand_Rscript( c(a_file, a_dir, a_glob), debug = T )
#> $`C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/foo.R`
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/foo.R"
#> 
#> $`C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/R`
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/R/a.R"
#> 
#> $`C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/*/*.R`
#> [1] "C:/Users/rd/AppData/Local/Temp/Rtmpyoxil6/temp_libpathe18826921c0d/fundoc/R/a.R"
#>