tribe (version 0.1.6)

stick_to: Work on a specific attribute within a pipeline

Description

The functions stick_to and unstick enable to select an attribute within a pipe and work on it.

It must be combined with the %@>% pipe to work properly, see the example below.

Usage

stick_to(obj, at)

stick_to_(obj, at)

unstick(x)

Arguments

obj

An object with an at attribute.

at

The name of the attribute to be considered.

x

An object to be unsticked. Must have ".obj_stick" and ".at_stick" attributes.

Value

stick_to basically inverses the roles of .data and at, meaning that .data becomes an attribute of the selected attribute. unstick makes the inverse operation.

Examples

Run this code
# NOT RUN {
library(dplyr)
library(observer)

df <- ggplot2::diamonds %>% 
  mutate(depth2 = 100*2*z/(x+y)) %>% 
  observe_if(abs(depth-depth2) < 1)

observations(df)

df %>% 
  stick_to(observations) %@>% 
  mutate(Id = 2) %@>% 
  select(Id, Status) %>% 
  unstick()

observations(df)

# }

Run the code above in your browser using DataCamp Workspace