-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,446 additions
and
500 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#' Import multiple files of any format from a directory into an environment. | ||
#' | ||
#' @param path A character vector of one path. | ||
#' @param .f A function able to read the desired file format. | ||
#' @inheritParams fs::dir_ls | ||
#' @inheritParams base::grep | ||
#' @inheritParams base::list2env | ||
#' @param ... Additional arguments passed to `.f`. | ||
#' | ||
#' @return `invisible(path)`. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' e <- new.env() | ||
#' load_any(tor_example("rdata"), .f = ~ get(load(.x)), envir = e) | ||
#' ls(e) | ||
#' | ||
#' # The data is now available in the environment `e` | ||
#' e$rdata1 | ||
#' e$rdata2 | ||
#' @family functions to import files into an environment | ||
#' @family functions to import files of any format | ||
load_any <- function(path = ".", | ||
.f, | ||
regexp = NULL, | ||
ignore.case = FALSE, | ||
invert = FALSE, | ||
envir = .GlobalEnv, | ||
...) { | ||
lst <- list_any( | ||
path = path, | ||
.f = .f, | ||
regexp = regexp, | ||
ignore.case = ignore.case, | ||
invert = invert, | ||
... | ||
) | ||
|
||
list2env(lst, envir = envir) | ||
invisible(path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.