library(dplyr)
library(dtrackr)
# mutate and other functions are unitary operations that generally change
# the structure but not size of a dataframe. In dtrackr these are by ignored
# by default but we can change that so that their behaviour is obvious.
# add_count
# adding in a count or tally column as a new column
iris %>%
track() %>%
add_count(Species, name="new_count_total",
.messages="{.new_cols}",
# .messages="{.cols}",
.headline="New columns from add_count:") %>%
history()
# add_tally
iris %>%
track() %>%
group_by(Species) %>%
dtrackr::add_tally(wt=Petal.Length, name="new_tally_total",
.messages="{.new_cols}",
.headline="New columns from add_tally:") %>%
history()
Run the code above in your browser using DataLab