• Stars
    star
    244
  • Rank 165,885 (Top 4 %)
  • Language
    R
  • License
    Other
  • Created over 6 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create tabs of View() output for each chained pipe

ViewPipeSteps

CRAN log

Installation

You can install the released version of ViewPipeSteps from CRAN with:

install.packages("ViewPipeSteps")

Or install the development version from GitHub with:

remotes::install_github("daranzolin/ViewPipeSteps")

Overview

ViewPipeSteps helps to debug pipe chains in a slightly more elegant fashion. Print/View debugging isnโ€™t sexy, but instead of manually inserting %>% View() after each step, spice it up a bit by, e.g., highlighting the entire chain and calling the viewPipeChain addin:

The View Pipe Chain Steps RStudio addin

Thanks to @batpigandme for the the gif!

Alternatively, you can:

  • Print each pipe step of the selction to the console by using the printPipeChain addin.
  • Print all pipe steps to the console by adding a print_pipe_steps() call to your pipe.
diamonds %>%
  select(carat, cut, color, clarity, price) %>%
  group_by(color) %>%
  summarise(n = n(), price = mean(price)) %>%
  arrange(desc(color)) %>%
  print_pipe_steps() -> result
## 1. diamonds

## # A tibble: 53,940 x 10
##    carat cut       color clarity depth table price     x     y     z
##    <dbl> <ord>     <ord> <ord>   <dbl> <dbl> <int> <dbl> <dbl> <dbl>
##  1 0.23  Ideal     E     SI2      61.5    55   326  3.95  3.98  2.43
##  2 0.21  Premium   E     SI1      59.8    61   326  3.89  3.84  2.31
##  3 0.23  Good      E     VS1      56.9    65   327  4.05  4.07  2.31
##  4 0.290 Premium   I     VS2      62.4    58   334  4.2   4.23  2.63
##  5 0.31  Good      J     SI2      63.3    58   335  4.34  4.35  2.75
##  6 0.24  Very Good J     VVS2     62.8    57   336  3.94  3.96  2.48
##  7 0.24  Very Good I     VVS1     62.3    57   336  3.95  3.98  2.47
##  8 0.26  Very Good H     SI1      61.9    55   337  4.07  4.11  2.53
##  9 0.22  Fair      E     VS2      65.1    61   337  3.87  3.78  2.49
## 10 0.23  Very Good H     VS1      59.4    61   338  4     4.05  2.39
## # โ€ฆ with 53,930 more rows

## 2. select(carat, cut, color, clarity, price)

## # A tibble: 53,940 x 5
##    carat cut       color clarity price
##    <dbl> <ord>     <ord> <ord>   <int>
##  1 0.23  Ideal     E     SI2       326
##  2 0.21  Premium   E     SI1       326
##  3 0.23  Good      E     VS1       327
##  4 0.290 Premium   I     VS2       334
##  5 0.31  Good      J     SI2       335
##  6 0.24  Very Good J     VVS2      336
##  7 0.24  Very Good I     VVS1      336
##  8 0.26  Very Good H     SI1       337
##  9 0.22  Fair      E     VS2       337
## 10 0.23  Very Good H     VS1       338
## # โ€ฆ with 53,930 more rows

## 4. summarise(n = n(), price = mean(price))

## # A tibble: 7 x 3
##   color     n price
##   <ord> <int> <dbl>
## 1 D      6775 3170.
## 2 E      9797 3077.
## 3 F      9542 3725.
## 4 G     11292 3999.
## 5 H      8304 4487.
## 6 I      5422 5092.
## 7 J      2808 5324.

## 5. arrange(desc(color))

## # A tibble: 7 x 3
##   color     n price
##   <ord> <int> <dbl>
## 1 J      2808 5324.
## 2 I      5422 5092.
## 3 H      8304 4487.
## 4 G     11292 3999.
## 5 F      9542 3725.
## 6 E      9797 3077.
## 7 D      6775 3170.
  • Try your luck with the experimental %P>% pipe variant that prints the output of the pipeโ€™s left hand side prior to piping it to the right hand side.
diamonds %>%
  select(carat, cut, color, clarity, price) %>%
  group_by(color) %>%
  summarise(n = n(), price = mean(price)) %P>%
  arrange(desc(color)) -> result
## Printing diamonds %>% select(carat, cut, color, clarity, price) %>% group_by(color) %>% summarise(n = n(), price = mean(price))

## # A tibble: 7 x 3
##   color     n price
##   <ord> <int> <dbl>
## 1 D      6775 3170.
## 2 E      9797 3077.
## 3 F      9542 3725.
## 4 G     11292 3999.
## 5 H      8304 4487.
## 6 I      5422 5092.
## 7 J      2808 5324.

Installation

devtools::install_github("daranzolin/ViewPipeSteps")

More Examples

Check tools/test_cases.R for more elaborate examples.

Future Work

  • Verify that %P>% is implemented in a useful way and does it what it is supposed to do.

More Repositories

1

rcanvas

R Client for Canvas LMS API
R
89
star
2

d3rain

An htmlwidget bringing D3 drip to R ๐Ÿ’ฆ โœจ ๐Ÿ“Š
R
77
star
3

inferregex

Infer the regular expression (regex) of a string ๐Ÿ”ค ๐Ÿ”ข ๐Ÿ”
R
53
star
4

hacksaw

Extra tidyverse-like functionality
R
33
star
5

compareBars

Simplify comparative bar charts ๐Ÿ“Š
JavaScript
28
star
6

quickglobe

๐ŸŒŽ View Country Data via a 3D, D3, Globe ๐ŸŒ
R
23
star
7

ggtextparallels

Text parallels created with ggplot2
R
17
star
8

funcreporter

Automate RMarkdown Reporting โœจ ๐Ÿ”ฅ ๐Ÿ’ƒ
R
13
star
9

ArcMap-to-R

Mapping the ArcMap toolbox to R's sf and raster packages
11
star
10

clockwork

Create cyclical, radial line charts with d3.js ๐Ÿ•
JavaScript
10
star
11

rCAEDDATA

The California Department of Education in R
R
8
star
12

textych

Create interactive text parallels ๐Ÿ“ƒ ๐Ÿ“ƒ ๐Ÿ“ƒ
JavaScript
8
star
13

pinpoint

Interactively explore points within a distribution ๐Ÿ“Œ
JavaScript
7
star
14

rcicero

R Client for Cicero API
R
7
star
15

freshAirFinderApp

R
6
star
16

kapow

๐Ÿ’ฃ Seamless variable assignment from R objects ๐Ÿ’ฅ
R
6
star
17

maxprepsr

Web scraper for www.maxpreps.com
R
5
star
18

typeStringsGadget

Type strings unencumbered
R
5
star
19

compareAreas

Shiny Gadget to compare areas (square meters, kilometers, feet, miles, and acres)
R
4
star
20

barah

Fashion a pattern out of chaos.
C++
4
star
21

dfdetective

๐Ÿ” Scour your data frames. Leave no row untouched. ๐Ÿ”
R
3
star
22

tidyTuesdaysD3

Tidy Tuesdays with D3 ๐Ÿ“ˆ ๐Ÿ“Š
JavaScript
3
star
23

env2list

Query the global environment a la 'tidyselect'-like helpers
R
2
star
24

datasfbot

Bot that tweets random DataSF geospatial content
R
2
star
25

reportsAsFunctions

R Package Demonstrating Creating Reports as Functions
R
2
star
26

cteviewer

Bring Intermediate CTE SQL Queries into RStudio
R
2
star
27

hacksawstats

Do simple stats fast w/ 'hacksaw-like' syntax
R
2
star
28

pmapply

Apply a function across pairs of vectors
R
1
star
29

rEvalKit

๐Ÿ“‹ Query the EvaluationKit REST API
R
1
star
30

sqltargets

targets extension for SQL queries
R
1
star
31

testdatapkg

Data for Environmental Data Science
R
1
star
32

funcreports

Sample Rmarkdown Templates
R
1
star
33

dailyPurpleAir

R
1
star
34

CA-School-District-Diversity

Application to explore ethnic diversity in California school districts
1
star
35

switchup

Switch up the values before and after '='
R
1
star
36

dputsql

Create 'CREATE TABLE' and 'INSERT INTO...VALUES' SQL statements from R objects
R
1
star
37

countem

Sit back, relax, and enjoy the bar charts
JavaScript
1
star
38

AJAXCalculator

JavaScript
1
star