click: Increment the tally counter

View source: R/tally.R

clickR Documentation

Increment the tally counter

Description

This function adds or subtracts one from the counter depending on the tally counter type used, defined within the tally_counter function. It returns the number padded to a minimum of four characters. Once counter has finished the environment and counter object are removed.

Usage

click()

Value

The count number padded to a minimum of four characters.

See Also

Other tally counter methods: tally_counter()

Examples

suppressPackageStartupMessages({
  suppressWarnings({
    library(palmerpenguins)
    library(dplyr)
    library(stringr)
    library(purrr)
  })
})

penguin_stats <- function(...) {

  # get row
  data <- list(...)

  # get penguins stats
  species <- purrr::pluck(data, "species")
  island <- purrr::pluck(data, "island")
  body_mass_g <- purrr::pluck(data, "body_mass_g")
  sex <- purrr::pluck(data, "sex")
  year <- purrr::pluck(data, "year")

  # print penguin stats
  message(stringr::str_glue("{click()} : The body mass for the {sex} {species} penguin recorded in {year} on {island} island is {body_mass_g} grams"))

}
penguin_stats_slow <- slowly(penguin_stats, rate_delay(0.1))

penguins %>%
  slice_sample(n = 10) %>%
  arrange(desc(body_mass_g)) %>%
  tally_counter(type = "add") %>%
  pwalk(penguin_stats_slow)

gcfrench/store documentation built on May 17, 2024, 5:52 p.m.