Skip to content

Commit

Permalink
Better example of load_*() variants (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolepore committed Jan 7, 2019
1 parent b53de95 commit a8e7df7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 38 deletions.
14 changes: 7 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ library(tor)

All functions list whatever they read, and default to reading from the working directory.

#### `list_*()`: Import multiple files from a directory into a list
### `list_*()`: Import multiple files from a directory into a list

```{r}
dir()
Expand Down Expand Up @@ -123,19 +123,19 @@ path_mixed %>%
list_any(~get(load(.)), regexp = "[.]csv$", invert = TRUE)
```

#### `load_*()`: Load multiple files from a directory into an environment
### `load_*()`: Load multiple files from a directory into an environment

All functions default to load from the working directory.

```{r}
rm(list = ls())
ls()
# The working directory contains .csv files
dir()
load_csv()
# Each dataframe is now available in the global environment
ls()
# Each file is now available as a dataframe in the global environment
csv1
csv2
```

You may load from a `path`.
Expand All @@ -153,7 +153,7 @@ ls()
rda
```

#### [__purrr__](https://purrr.tidyverse.org/) + `format_path()`: Map each list element to a file in a directory
### [__purrr__](https://purrr.tidyverse.org/) + `format_path()`: Map each list element to a file in a directory

__tor__ does not write data but includes a helper to create the paths to output files.

Expand Down
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ library(tor)
All functions list whatever they read, and default to reading from the
working directory.

#### `list_*()`: Import multiple files from a directory into a list
### `list_*()`: Import multiple files from a directory into a list

``` r
dir()
Expand Down Expand Up @@ -300,24 +300,32 @@ path_mixed %>%
#> 2 b
```

#### `load_*()`: Load multiple files from a directory into an environment
### `load_*()`: Load multiple files from a directory into an environment

All functions default to load from the working directory.

``` r
rm(list = ls())
ls()
#> character(0)
# The working directory contains .csv files
dir()
#> [1] "_pkgdown.yml" "cran-comments.md" "CRAN-RELEASE"
#> [4] "csv1.csv" "csv2.csv" "datasets"
#> [7] "DESCRIPTION" "docs" "inst"
#> [10] "LICENSE.md" "man" "NAMESPACE"
#> [13] "NEWS.md" "R" "README.md"
#> [16] "README.Rmd" "tests" "tmp.R"
#> [19] "tor.Rproj"

load_csv()

# Each dataframe is now available in the global environment
ls()
#> [1] "csv1" "csv2"
# 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`.
Expand Down Expand Up @@ -345,7 +353,7 @@ rda
#> 2 b
```

#### [**purrr**](https://purrr.tidyverse.org/) + `format_path()`: Map each list element to a file in a directory
### [**purrr**](https://purrr.tidyverse.org/) + `format_path()`: Map each list element to a file in a directory

**tor** does not write data but includes a helper to create the paths to
output files.
Expand Down
52 changes: 30 additions & 22 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a8e7df7

Please sign in to comment.