Description Usage Arguments Value Examples
View source: R/talk_replace_all.R
Talk to Replace all types a Data set
| 1 2 3 4 5 6 7 8 9 10 | talk_replace(.data, cmd, verbose = FALSE, ...)
talk_replace_expr(
  data_colnames,
  cmd,
  allowed_words = c("factor", "logical", "numeric", "character", "double"),
  ...
)
talk_process_replace_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 | library(tibble)
library(dplyr)
df = mtcars %>%
  rownames_to_column(var = "car")
  cmds = c(
    "replace gear mpg as factors",
    "replace car as factor",
    "replace gear as character")
 data_colnames = df
 .data = df
 cmd = cmds[1]
 results = lapply(cmds, talk_replace, .data = df)
 testthat::expect_warning(talk_replace(.data, cmd),
 "allowed")
df = df %>%
  rename(GEAR = gear)
 gear = df %>%
 talk_replace("replace by gear and column 3 as factors")
 d_classes = sapply(gear[, c("cyl", "GEAR")], class)
testthat::expect_true(all(d_classes == "factor"))
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.