print_pipe: Print result of a pipe

View source: R/print_pipe.R

print_pipeR Documentation

Description

Sometimes when I am working on a series of piped code, I want to see the interim results when I am adding lines etc. It used to be that you could add ⁠%>% {.}⁠ with the pipe command from magrittr package (you still can), but this does not work with the native pipe ⁠|>⁠. This is my workaround.

Usage

print_pipe(x, n = NULL)

Arguments

x

An object or value from a previous pipe to print.

n

Number of rows to print.

Details

A wrapper around x %>% print() or x |> print()

Examples

library(dplyr)
library(palmerpenguins)


penguins |>
  group_by(species) |>
  summarise(mean_bill_length_mm = mean(bill_length_mm, na.rm = TRUE)) |>
  print_pipe()

penguins |>
  print_pipe()

penguins |>
  print_pipe(n = Inf)

emilelatour/lamisc documentation built on April 9, 2024, 10:33 a.m.