Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
elbersb committed Aug 6, 2019
1 parent 576a8bd commit d4eff25
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 23 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: tidylog
Type: Package
Title: Logging for 'dplyr' Functions
Title: Logging for 'dplyr' and 'tidyr' Functions
Version: 0.1.0.9000
Authors@R: person("Benjamin", "Elbers", email = "elbersb@gmail.com",
role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5392-3448"))
Description: Provides feedback about basic 'dplyr' operations.
Description: Provides feedback about 'dplyr' and 'tidyr' operations.
License: MIT + file LICENSE
Imports: dplyr, tidyr, glue, clisymbols
Suggests: testthat, covr, lintr
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 0.1.0.9000
- wrap new functions for `tidyr::gather()`, `tidyr::spread()` (thanks [@WilDoane](https://github.com/WilDoane)) and `tidyr::drop_na()`([@jackhannah95](https://github.com/jackhannah95))
- added supoort for tidyr functions: gather, spread, drop_na (thanks @WilDoane and @jackhannah95)
- use clisymbols for ellipsis
- add number of remaining rows to filter (#23)
- bugfix: do not report negative NA (#18)
Expand Down
20 changes: 10 additions & 10 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ knitr::opts_chunk$set(
[![Build Status](https://travis-ci.org/elbersb/tidylog.svg?branch=master)](https://travis-ci.org/elbersb/tidylog)
[![Coverage status](https://codecov.io/gh/elbersb/tidylog/branch/master/graph/badge.svg)](https://codecov.io/github/elbersb/tidylog?branch=master)

The goal of tidylog is to provide feedback about basic dplyr and tidyr operations. It provides simple wrapper functions for the most common functions, such as `filter`, `mutate`, `select`, `full_join`, and `group_by`.
The goal of tidylog is to provide feedback about dplyr and tidyr operations. It provides simple wrapper functions for the most common functions, such as `filter`, `mutate`, `select`, `full_join`, and `group_by`.

## Example

Expand Down Expand Up @@ -65,7 +65,7 @@ devtools::install_github("elbersb/tidylog")

## More examples

### filter, distinct, drop_na (tidyr)
### filter, distinct, drop_na

```{r}
a <- filter(mtcars, mpg > 20)
Expand Down Expand Up @@ -134,7 +134,7 @@ c <- mtcars %>% count(gear, carb)
d <- mtcars %>% add_count(gear, carb, name = "count")
```

### gather, spread (tidyr)
### gather, spread

```{r}
long <- mtcars %>%
Expand All @@ -147,7 +147,7 @@ wide <- long %>%
## Turning logging off, registering additional loggers

To turn off the output for just a particular function call, you can simply call the dplyr and tidyr functions
directly, e.g. `dplyr::filter` and `tidyr::drop_na`.
directly, e.g. `dplyr::filter` or `tidyr::drop_na`.

To turn off the output more permanently, set the global option `tidylog.display` to an empty list:

Expand All @@ -166,7 +166,7 @@ simply overwrite the option:

```{r}
library("crayon") # for terminal colors
crayon <- function(x) cat(red$bold(x), sep = "\n")
crayon <- function(x) cat(red$bold(x), sep = "\n")
options("tidylog.display" = list(crayon))
a <- filter(mtcars, mpg > 20)
```
Expand All @@ -184,11 +184,11 @@ a <- filter(mtcars, mpg > 20)
Tidylog redefines several of the functions exported by dplyr and tidyr, so it should be loaded last, otherwise there will be no output. A more explicit way to resolve namespace conflicts is to use the [conflicted](https://CRAN.R-project.org/package=conflicted) package:

``` r
library(dplyr)
library(tidyr)
library(tidylog)
library(conflicted)
library("dplyr")
library("tidyr")
library("tidylog")
library("conflicted")
for (f in getNamespaceExports("tidylog")) {
conflicted::conflict_prefer(f, 'tidylog', quiet = TRUE)
conflicted::conflict_prefer(f, "tidylog", quiet = TRUE)
}
```
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Status](https://travis-ci.org/elbersb/tidylog.svg?branch=master)](https://travis
[![Coverage
status](https://codecov.io/gh/elbersb/tidylog/branch/master/graph/badge.svg)](https://codecov.io/github/elbersb/tidylog?branch=master)

The goal of tidylog is to provide feedback about basic dplyr and tidyr
The goal of tidylog is to provide feedback about dplyr and tidyr
operations. It provides simple wrapper functions for the most common
functions, such as `filter`, `mutate`, `select`, `full_join`, and
`group_by`.
Expand Down Expand Up @@ -70,7 +70,7 @@ devtools::install_github("elbersb/tidylog")

## More examples

### filter, distinct, drop\_na (tidyr)
### filter, distinct, drop\_na

``` r
a <- filter(mtcars, mpg > 20)
Expand Down Expand Up @@ -178,7 +178,7 @@ d <- mtcars %>% add_count(gear, carb, name = "count")
#> add_count: new variable 'count' with 5 unique values and 0% NA
```

### gather, spread (tidyr)
### gather, spread

``` r
long <- mtcars %>%
Expand All @@ -195,7 +195,7 @@ wide <- long %>%

To turn off the output for just a particular function call, you can
simply call the dplyr and tidyr functions directly, e.g. `dplyr::filter`
and `tidyr::drop_na`.
or `tidyr::drop_na`.

To turn off the output more permanently, set the global option
`tidylog.display` to an empty list:
Expand All @@ -217,7 +217,7 @@ output, simply overwrite the option:

``` r
library("crayon") # for terminal colors
crayon <- function(x) cat(red$bold(x), sep = "\n")
crayon <- function(x) cat(red$bold(x), sep = "\n")
options("tidylog.display" = list(crayon))
a <- filter(mtcars, mpg > 20)
#> filter: removed 18 rows (56%), 14 rows remaining
Expand All @@ -240,11 +240,11 @@ explicit way to resolve namespace conflicts is to use the
[conflicted](https://CRAN.R-project.org/package=conflicted) package:

``` r
library(dplyr)
library(tidyr)
library(tidylog)
library(conflicted)
library("dplyr")
library("tidyr")
library("tidylog")
library("conflicted")
for (f in getNamespaceExports("tidylog")) {
conflicted::conflict_prefer(f, 'tidylog', quiet = TRUE)
conflicted::conflict_prefer(f, "tidylog", quiet = TRUE)
}
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
library("dplyr")
library("tidyr")
library("tidylog")
context("test_gather")

Expand Down Expand Up @@ -28,3 +29,30 @@ test_that("gather: argument order", {

expect_equal(out_ab, out_ba)
})

test_that("spread", {
expect_message({
outlog <- tidylog::spread(mtcars, hp, carb)
})
expect_equal(nrow(outlog), 32)
expect_equal(ncol(outlog), 31)

expect_silent({
outtidyr <- tidyr::spread(mtcars, hp, carb)
})

expect_equal(outlog, outtidyr)

})

test_that("spread: argument order", {
expect_message({
out_ab <- tidylog::spread(.data = mtcars, hp, carb)
})

expect_message({
out_ba <- tidylog::spread(hp, carb, .data = mtcars)
})

expect_equal(out_ab, out_ba)
})

0 comments on commit d4eff25

Please sign in to comment.