Description Usage Arguments Value Examples
View source: R/talk_group_by.R
Talk to Group a Data set
1 2 3 4 5 | talk_group_by(.data, cmd, verbose = FALSE, ...)
talk_group_by_expr(data_colnames, cmd, allowed_words = "", ...)
talk_process_group_by_cmd(cmd)
|
.data |
The data set/ |
cmd |
Command to perform on the data set. |
verbose |
print diagnostic output |
... |
additional arguments to pass to |
data_colnames |
column names of the data |
allowed_words |
words allowed to be in the command other than the column names |
A data.frame
or list of them if length(cmds) > 1
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | library(tibble)
library(dplyr)
df = mtcars %>%
rownames_to_column(var = "car")
cmds = c(
"group by mpg",
"Group by column mpg ",
"group by column 5",
"arrange by gear",
"group by columns 4 and 5",
"group by columns 4 and 5, mpg",
# duplciate
"group by columns 2 and 5, mpg",
"group by columns 4, 5, and 6",
"group by mpg descending",
"group by mpg",
"group by mpg",
"group by mpg low to high")
data_colnames = df
.data = df
results = lapply(cmds, talk_group_by, .data = df)
cmd = "group by columns 2 and 5, mpg decreasing"
testthat::expect_warning(talk_group_by(.data, cmd),
"allowed")
df = df %>%
rename(GEAR = gear)
gear = df %>%
talk_group_by("arrange by gear and column 3")
testthat::expect_true(all(group_vars(gear) == c("GEAR", "cyl")))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.