Description Usage Arguments Value Examples
Talk to Filter a Data set
1 2 3 4 5 | talk_select(.data, cmd, verbose = FALSE, ...)
talk_select_expr(data_colnames, cmd, ...)
talk_process_select_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 |
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 | library(tibble)
library(dplyr)
df = tibble::rownames_to_column(mtcars, var = "car")
df = df %>%
rename(cylinders = cyl,
horsepower = hp,
American = am,
carburetor = carb)
.data = df
cmds = c("subset columns 5 and 6",
"select column horsepower",
"drop columns 1 and 3 american",
"select MPG column four 5")
cmd = cmds
data_colnames = colnames(df)
exprs = sapply(cmds, talk_select_expr, data_colnames = df)
exprs = sapply(exprs, function(x) x$condition)
results = lapply(cmds, talk_select, .data = df)
cyl = df %>%
talk_select("select if cylinders American")
testthat::expect_true(all(colnames(cyl) == c("cylinders", "American")))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.