talk_select: Talk to Filter a Data set

Description Usage Arguments Value Examples

View source: R/talk_select.R

Description

Talk to Filter a Data set

Usage

1
2
3
4
5
talk_select(.data, cmd, verbose = FALSE, ...)

talk_select_expr(data_colnames, cmd, ...)

talk_process_select_cmd(cmd)

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

data_colnames

column names of the data

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
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")))

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