add_zero_state: Duplicate dataset with zero values for one variable

View source: R/hacks.R

add_zero_stateR Documentation

Duplicate dataset with zero values for one variable

Description

This function duplicates a dataset, using a variable 'state' to distinguish the two copies: the original version has 'state=1', the copy has 'state=0'.

Usage

add_zero_state(df, value)

Arguments

df

the dataframe

value

the variable that will be reset as zero in the copy dataset.

Details

The copy also sets 'value = 0' throughout. Useful in conjunction with 'transition_state()'. Eg for a bar plot, state = 1, the actual values, where an animation ends. state = 0, all plotted values set to 0, where an animation starts.


bbcuffer/rcutils documentation built on Nov. 10, 2023, 12:08 p.m.