talk_regress: Talk to Group a Data set

Description Usage Arguments Value Examples

View source: R/talk_regress.R

Description

Talk to Group a Data set

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
talk_regress(.data, cmd, tidy = TRUE, verbose = FALSE, ...)

talk_regress_links()

talk_regress_families()

talk_regress_expr(
  data_colnames,
  cmd,
  allowed_words = c("condition", talk_regress_links(), talk_regress_families()),
  ...
)

talk_process_regress_cmd(cmd)

Arguments

.data

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

cmd

Command to perform on the data set.

tidy

should tidy be run?

verbose

print diagnostic output

...

additional arguments to pass to talk_get_colnames or tidy

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
19
20
21
22
23
24
25
26
27
library(tibble)
library(dplyr)
df = mtcars %>%
  rownames_to_column(var = "car")
  cmds = c(
    "regress  mpg on cyl and hp",
    "regress  mpg on cyl and hp columns 4",
    "regress  mpg on cyl and hp and column 6",
    "regress am on  hp and column 6 on mpg binomial",
    "regress am on  hp and column 6 on mpg binomial logit link"
    )
 data_colnames = df
 .data = df
 results = lapply(cmds, talk_regress, .data = df)
 cmd = "regress mpg on cyl and hp and column 6 poisson"
 mod_1 = talk_regress(.data, cmd)
 cmd = "regress poisson cyl and hp and column 6 on mpg"
 mod_2 = talk_regress(.data, cmd)
 testthat::expect_equal(coef(mod_1), coef(mod_2))
 cmd = "regress poisson cyl and hp and column 6 on mpg"
 mod_2 = talk_regress(.data, cmd, exponentiate = TRUE)

 cmd = "regress am on  hp and column 6 and mpg binomial"
 #'
 cmd =  "regress columns 2 and 5, mpg decreasing"
 testthat::expect_error(talk_regress(.data, cmd),
 "y variable")

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