Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow targets::tar_source to chdir change directory to the source file #1040

@dipterix

Description

@dipterix

Prework

  • I understand and agree to help guide.
  • I understand and agree to contributing guide.
  • New features take time and effort to create, and they take even more effort to maintain. So if the purpose of the feature is to resolve a struggle you are encountering personally, please consider first posting a "trouble" or "other" issue so we can discuss your use case and search for existing solutions first.

Proposal

Allow source to change directory when sourcing external scripts. Default to FALSE to be compatible (have exactly the same behavior) with current implementation.

targets::tar_source <- function (files = "R", chdir = FALSE, envir = targets::tar_option_get("envir")) 
{
    ...
    lapply(r_scripts, function(file) {
        # eval(parse(text = readLines(file, warn = FALSE)), envir = envir)
		source(file, local = envir, chdir = chdir, keep.source = FALSE)
        invisible()
    })
    invisible()
}

Alternatively sys.source could replace source

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions