diff --git a/README.Rmd b/README.Rmd index 0934346..7db0512 100644 --- a/README.Rmd +++ b/README.Rmd @@ -39,7 +39,7 @@ library(fs) library(tor) ``` -All functions list whatever they read, and default to reading from the working directory. +All functions list whatever they read, and default to reading from the working directory. Dataframes are coerced to tibbles. ### `list_*()`: Import multiple files from a directory into a list diff --git a/README.md b/README.md index 45c50f7..4495223 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ library(tor) ``` All functions list whatever they read, and default to reading from the -working directory. +working directory. Dataframes are coerced to tibbles. ### `list_*()`: Import multiple files from a directory into a list diff --git a/docs/index.html b/docs/index.html index 3026957..40881ec 100644 --- a/docs/index.html +++ b/docs/index.html @@ -102,7 +102,7 @@
All functions list whatever they read, and default to reading from the working directory.
+All functions list whatever they read, and default to reading from the working directory. Dataframes are coerced to tibbles.
list_*()
: Import multiple files from a directory into a listOften you will specify a path
to read from.
# Helpes create paths to examples
tor_example()
@@ -192,14 +196,18 @@
list_any(path_csv, read.csv)
#> $csv1
-#> x
-#> 1 1
-#> 2 2
-#>
-#> $csv2
-#> y
-#> 1 a
-#> 2 b
It understands lambda functions and formulas (powered by rlang).
(path_rdata <- tor_example("rdata"))
#> [1] "C:/Users/LeporeM/Documents/R/R-3.5.2/library/tor/extdata/rdata"
@@ -340,13 +348,17 @@
# Each file is now available as a dataframe in the global environment
csv1
-#> x
-#> 1 1
-#> 2 2
-csv2
-#> y
-#> 1 a
-#> 2 b
You may load from a path
.
rm(list = ls())
ls()
@@ -395,22 +407,26 @@
(dfs <- list_csv())
#> $csv1
-#> x
-#> 1 1
-#> 2 2
-#>
-#> $csv2
-#> y
-#> 1 a
-#> 2 b
-
-paths <- dfs %>%
- imap_chr(~ format_path(.y, "csv", base = ".", prefix = "this-"))
-
-walk2(dfs, paths, readr::write_csv)
-
-dir_ls(".", regexp = "this-")
-#> this-csv1.csv this-csv2.csv
tibble::as_tibble()
.load_*()
variants load each file in a directory into an environment.+format_path(names(dfs), "csv", base = "home", prefix = "this-")#> [1] "./file1.csv" "./file2.csv"#> $csv1 -#> x -#> 1 1 -#> 2 2 +#> # A tibble: 2 x 1 +#> x +#> <int> +#> 1 1 +#> 2 2 #> #> $csv2 -#> y -#> 1 a -#> 2 b +#> # A tibble: 2 x 1 +#> y +#> <chr> +#> 1 a +#> 2 b #>#> [1] "./csv1.csv" "./csv2.csv"#> [1] "home/this-csv1.csv" "home/this-csv2.csv"
#> [1] "C:/Users/LeporeM/Documents/Dropbox/git/ml/tor/inst/extdata/csv"dir(path_csv)#> [1] "csv1.csv" "csv2.csv"load_csv(path_csv) # Each dataframe is now available in the global environment -csv1#> x -#> 1 1 -#> 2 2csv2#> y -#> 1 a -#> 2 b+csv1#> # A tibble: 2 x 1 +#> x +#> <int> +#> 1 1 +#> 2 2csv2#> # A tibble: 2 x 1 +#> y +#> <chr> +#> 1 a +#> 2 b#> [1] "C:/Users/LeporeM/Documents/Dropbox/git/ml/tor/inst/extdata/mixed"dir(path_mixed)#> [1] "csv.csv" "lower_rdata.rdata" "rda.rda" #> [4] "upper_rdata.RData"load_rdata(path_mixed) # Each dataframe is now available in the global environment -lower_rdata#> # A tibble: 2 x 1 +lower_rdata#> # A tibble: 2 x 1 #> y #> <chr> #> 1 a