File Management and Location tools
Install the development version from Github with:
## install remotes pkg if not already
if (!requireNamespace("remotes", quietly = TRUE)) {
install.packages("remotes")
}
## install from github
remotes::install_github("mkearney/fml")find_file(): find a file (exact matches)
## find the rtweet readme
find_file("rtweet", "README.Rmd")
#> [1] "/Users/mwk/R/rtweet/README.Rmd"search_file(): search for files using wildcard expansion*: match zero or more characters?: match a single character[: begin a character class or range
## starts with capital letter and doesn't end with md/html
search_file("[A-Z]*[!md|html]")
#> [1] "/Users/mwk/R/fml/DESCRIPTION" "/Users/mwk/R/fml/LICENSE"
#> [3] "/Users/mwk/R/fml/NAMESPACE" "/Users/mwk/R/fml/docs/CNAME"
## all .yml files not in docs/
search_file("[!docs]*.yml")
#> [1] "/Users/mwk/R/fml/_pkgdown.yml" "/Users/mwk/R/fml/docs/pkgdown.yml"
## .yml files that start with a dot
search_file(".*.yml")
#> [1] "/Users/mwk/R/fml/.travis.yml"here(): smart file paths within project
## locate file in project
here("R", "fp.R")
#> [1] "/Users/mwk/R/fml/R/fp.R"list_files(): list files
## list files in directory
list_files(full = FALSE)
#> [1] "_pkgdown.yml" "codecov.yml" "DESCRIPTION" "fml.Rproj"
#> [5] "LICENSE" "LICENSE.md" "NAMESPACE" "README.md"
#> [9] "README.Rmd"list_dirs(): list directories
## list dirs in directory
list_dirs(full = FALSE)
#> [1] "docs" "man" "pkgdown" "R" "tests"list_paths(): list all paths
## list files AND paths in directory
list_paths(full = FALSE)
#> [1] "_pkgdown.yml" "codecov.yml" "DESCRIPTION" "docs"
#> [5] "fml.Rproj" "LICENSE" "LICENSE.md" "man"
#> [9] "NAMESPACE" "pkgdown" "R" "README.md"
#> [13] "README.Rmd" "tests"fp(): construct file path
## build this/that
fp("this", "that")
#> [1] "this/that"
## pipe style
"this" %FP% "that"
#> [1] "this/that"pe(): path expansionβconverts to canonical form
## build this/that
pe(fp(".", "this", "that"))
#> [1] "./this/that"
## pipe style
pe("~" %FP% "this" %FP% "that")
#> [1] "/Users/mwk/this/that"