Working in the Tidyverse

respR integrates nicely with the tidyverse, specifically with dplyr functions e.g. select(), filter() and mutate(), and magrittr pipe operators (“%>%”) to clearly express workflows in an organised sequence.

It also works with the new native pipe operator (|>) introduced in R v4.1, however the dpylr pipes have some additional functionality. For more information, see the Pipes chapter in the online R for Data Science book.


Here we show how using %>% pipes can make data analysis worklows simpler for the user.

Typical analysis using regular R syntax:

# 1. check data for errors, select cols 1 and 15:
urch <- inspect(urchins.rd, 1, 15) 
# 2. automatically determine linear segment:
rate <- auto_rate(urch)
# 3. convert units
out <- convert_rate(rate, "mg/l", "s", "mg/h/kg", 0.6, 0.4)

Alternatively, use tidyverse pipes:

urchins.rd %>%        # using the urchins dataset,
  select(1, 15) %>%   # select columns 1 and 15
  inspect()     %>%   # inspect the data, then
  auto_rate()   %>%   # automatically determine most linear segment
  convert_rate("mg/l", "s", "mg/h/kg", 0.6, 0.4) # convert units