Add a final link to a dplyr or ggplot chain to make testing chains nice.
nowt(x = NULL)
A dplyr or ggplot2 object
a dplyr result or ggplot object that is the same as it went into the function.
Credit for the function goes to Duncan Garmonsway and Hadley Wickham
Garmonsway (2019, Jan. 31). Duncan Garmonsway: Add nowt() to your tidy pipelines. Retrieved from https://nacnudus.github.io/duncangarmonsway/posts/2019-01-31-add-nowt-to-your-tidy-pipelines/
library(dplyr)
#> Warning: package 'dplyr' was built under R version 4.1.3
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.1.3
data(mtcars)
mtcars %>%
group_by(cyl) %>%
summarise(mean(mpg)) %>%
# rename(mean_mpg = mean(mpg)) %>%
nowt()
#> # A tibble: 3 x 2
#> cyl `mean(mpg)`
#> <dbl> <dbl>
#> 1 4 26.7
#> 2 6 19.7
#> 3 8 15.1
p <- ggplot(mtcars, aes(x = disp, y = mpg)) +
geom_point() +
# scale_x_continuous("Displacement") +
nowt()
p