stick_to: Work on a specific attribute within a pipeline

Description Usage Arguments Value Examples

View source: R/stick_to.R

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

1
2
3
4
5
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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)

## End(Not run)

tribe documentation built on Dec. 1, 2019, 1:24 a.m.