talk_count: Talk to Count a Data set

Description Usage Arguments Value Examples

View source: R/zzz_talk_count.R

Description

Talk to Count a Data set

Usage

1
2
3
4
5
6
7
talk_count(.data, cmd, verbose = FALSE, ...)

talk_add_count(.data, cmd, verbose = FALSE, ...)

talk_counter(.data, cmd, verbose = FALSE, add = FALSE, ...)

talk_count_expr(data_colnames, cmd, allowed_words = "", ...)

Arguments

.data

The data set/data.frame to perform the operation.

cmd

Command to perform on the data set.

verbose

print diagnostic output

...

additional arguments to pass to talk_get_colnames

add

argument not for general use, but passed down to allow for switching between count/tally and add_count/add_tally

data_colnames

column names of the data

allowed_words

words allowed to be in the command other than the column names

Value

A data.frame or list of them if length(cmds) > 1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(tibble)
library(dplyr)
df = mtcars %>%
  rownames_to_column(var = "car")
  cmds = c(
    "count by  mpg",
    "count up mpg, hp",
    "count up mpg, hp, mpg")
 data_colnames = df
 .data = df
 results = lapply(cmds, talk_count, .data = df)
df = df %>%
  rename(GEAR = gear)
data_colnames = df
cmd = "count by gear "
 gear = df %>%
 talk_count("count by gear ")
testthat::expect_true(all(colnames(gear) == c("GEAR", "n")))

muschellij2/talkr documentation built on Jan. 20, 2020, 7:49 p.m.