Skip to content

Commit

Permalink
Merge 03a502c into b48f66c
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolepore committed Jan 9, 2019
2 parents b48f66c + 03a502c commit d1406d7
Show file tree
Hide file tree
Showing 34 changed files with 642 additions and 1,820 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
^vignettes$
^\.buildignore$
^vignettes/siteonly$
^cran-comments\.md$
^CRAN-RELEASE$
^docs$
Expand Down
89 changes: 89 additions & 0 deletions .buildignore/tor-1-0-0.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: "tor 1.0.0"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{tor 1.0.0}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
install.packages(
here::here(".buildignore/tor_1.0.0.zip"),
repos = NULL, type = "win.binary"
)
```

I'm happy to announce that __tor__ 1.0.0 in now on CRAN!

__tor__ (to-R) helps you to
read multiple files from a single directory into R, as simply as possible. It makes a frequent task less painful. __tor__ is particularly useful during quick, exploratory data analysis and works well with the [tidyverse](https://www.tidyverse.org/).

This initial release is minimal. It delivers the most useful functionality with few dependencies. Install the latest version of __tor__ from CRAN with:

```
install.packages("tor")
```

(Or [install the development version from GitHub](https://maurolepore.github.io/tor/index.html) which includes [exciting new features](https://maurolepore.github.io/tor/news/index.html).)

---

```{r}
library(tor)
```

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

`list_csv()` and friends import multiple files from a directory into a list.

```{r}
dir()
list_csv()
```

You may import specific files matching a pattern.

```{r}
(path_mixed <- tor_example("mixed"))
dir(path_mixed)
list_rdata(path_mixed, regexp = "[.]RData", ignore.case = FALSE)
```

`list_any()` is the most flexible function. You supply the function to read with.

```{r}
(path_csv <- tor_example("csv"))
dir(path_csv)
list_any(path_csv, readr::read_csv)
```

It understands lambda functions and formulas (powered by [__rlang__](https://rlang.r-lib.org/)).

```{r}
# Use the pipe (%>%)
library(magrittr)
(path_rdata <- tor_example("rdata"))
dir(path_rdata)
path_rdata %>%
list_any(function(x) get(load(x)))
# Same
path_rdata %>%
list_any(~get(load(.x)))
```

```{r, include=FALSE}
devtools::install_github("maurolepore/tor", upgrade = "never")
```

Binary file added .buildignore/tor_1.0.0.zip
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
inst/doc
.Rhistory
.RData
.Rproj.user
Expand Down
2 changes: 0 additions & 2 deletions CRAN-RELEASE

This file was deleted.

21 changes: 12 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
Package: tor
Title: Read Multiple Files With Of Any Format From a Directory
Into a List
Version: 1.0.0.9000
Title: Import Multiple Files From a Single Directory at Once
Version: 1.0.1.9000
Authors@R:
person(given = "Mauro",
family = "Lepore",
role = c("aut", "cre"),
email = "maurolepore@gmail.com")
Description: The goal of tor (to-R) is to help you to read
multiple files from a single directory into R, and to do so as
quickly, flexibly, and simply as possible. It makes a frequent,
challenging task less painful.
Description: The goal of tor (to-R) is to help you to import
multiple files from a single directory at once, and to do so as
quickly, flexibly, and simply as possible. It makes a frequent, task
less painful.
License: GPL-3
URL: https://github.com/maurolepore/tor
BugReports: https://github.com/maurolepore/tor/issues
Imports:
fs,
readr,
rlang,
tibble,
readr
tibble
Suggests:
covr,
knitr,
rmarkdown,
spelling,
testthat
VignetteBuilder:
knitr
Encoding: UTF-8
Language: en-US
LazyData: true
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by roxygen2: do not edit by hand

export(format_path)
export(list_any)
export(list_csv)
export(list_rdata)
Expand Down
29 changes: 2 additions & 27 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# tor 1.0.9001 unreleased
# tor 1.0.1.9000

## Minor

* `list_any()`, `list_csv()`, `list_tsv()`, `load_csv()`, and `load_tsv()` now use __readr__.
* This makes reading data faster and safer.

* Each dataframe output is now converted to tibble.
* Users no longer need to call `tibble::as_tibble()`.

* New `load_*()` variants load each file in a directory into an environment.

## Patch

* File names now emphasize the most common case when users import .csv files.

* Example data is now named more consistently. For example:
* `dir(tor_example("rds"))` returns `c("rds1.rds", "rds2.rds")`.
* `dir(tor_example("csv"))` returns `c("csv1.csv", "csv2.csv")`.

* Source is now styled with `styler::style_pkg()` (defaults)

* Lambda functions in source code now use the more common function(x) syntax.
* Text editors highlight `function()` which makes code easier to read.

# tor 1.0.0

* Initial release.
* Work in progress for the initial release.
36 changes: 0 additions & 36 deletions R/format_path.R

This file was deleted.

61 changes: 0 additions & 61 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,6 @@ The goal of __tor__ (_to-R_) is to make importing data into R ridiculously easy.
devtools::install_github("maurolepore/tor")
```

## Motivation

Your nickname is R-guru. Your colleague enjoys analyzing data and she head that R is great.

> I have a couple of minutes before the next meeting. Can you please show me how to start playing with some data in R?
TWO MINUTES?!

Don't panic. __tor__ is here to help you.

```{r}
# Here I have a bunch of files, including some .csv files with data.
dir()
# I "open" the programs I need to read the .csv files.
library(tor)
# And I list the data in all those .csv files
list_csv()
# Done.
```

## Example

```{r}
Expand Down Expand Up @@ -176,44 +153,6 @@ ls()
rda
```

### [__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.

```{r}
dir(pattern = "[.]csv$")
dfms <- list_csv()
format_path(names(dfms), "csv")
format_path(names(dfms), "csv", base = "home", prefix = "this-")
```

Combine it with [__purrr__](https://purrr.tidyverse.org/).

```{r}
library(purrr)
library(fs)
imap_chr(dfms, ~ format_path(.y, "csv"))
# Same
map_chr(dfms, ~ format_path(names(.), "csv", ".", "this-"))
(dfs <- list_csv())
paths <- dfs %>%
imap_chr(~ format_path(.y, "csv", base = ".", prefix = "this-"))
walk2(dfs, paths, readr::write_csv)
dir_ls(".", regexp = "this-")
```

```{r include=FALSE}
fs::file_delete(fs::dir_ls(".", regexp = "this-"))
```

# Related projects

Expand Down
Loading

0 comments on commit d1406d7

Please sign in to comment.