talk_get_colnames: Talk to Arrange a Data set

Description Usage Arguments Value Examples

View source: R/talk_get_colnames.R

Description

Talk to Arrange a Data set

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
talk_get_colnames(
  data_colnames,
  cmd,
  stop_words = talkr::talk_stop_words,
  additional_stop_words = NULL,
  remove_duplicated = TRUE,
  allowed_words = c("descending", "ascending"),
  ...
)

talk_cmd_to_colnames(
  data_colnames,
  cmd,
  stop_words = talkr::talk_stop_words,
  additional_stop_words = NULL
)

talk_check_colnames(data_colnames)

Arguments

data_colnames

column names of the data

cmd

Command to perform on the data set.

stop_words

Words to remove from the command

additional_stop_words

additional stop words to remove. Helpful if you want to pass in these words instead of with stop_words

remove_duplicated

remove duplicated columns in the command

allowed_words

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

...

additional arguments to pass to talk_get_colnames

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
22
23
24
25
library(tibble)
library(dplyr)
df = mtcars %>%
  rownames_to_column(var = "car")
  cmds = c(
    "Sort by  mpg",
    "Sort by  column    mpg  ",
    "arrange by column 5",
    "arrange by gear",
    "arrange by columns 4 and 5",
    "arrange by columns 4 and 5, mpg decreasing",
    # duplciate
    "arrange by columns 2 and 5, mpg decreasing",
    "arrange by columns 4, 5, and 6",
    "sort by mpg descending",
    "sort by mpg ascending",
    "sort by mpg ascending",
    "sort by mpg low to high hat")
 data_colnames = df
 cmd = "arrange by columns 4 and 5, mpg decreasing"
 results = lapply(cmds, talk_get_colnames, data_colnames = df)
 results = lapply(cmds, talk_get_colnames, data_colnames = df,
 allowed_words = "")
 results = lapply(cmds, talk_get_colnames, data_colnames = df,
 allowed_words = NULL)

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