Description Usage Arguments Value Examples
Talk to Arrange a Data set
1 2 3 4 5 | talk_arrange(.data, cmd, verbose = FALSE, ...)
talk_arrange_expr(data_colnames, cmd, ...)
talk_process_arrange_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 22 23 24 25 26 27 28 29 30 | 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")
results = lapply(cmds, talk_arrange, .data = df)
df = df %>%
rename(GEAR = gear)
cmd = "arrange by gear descending"
data_colnames = df
gear = df %>%
talk_arrange("arrange by gear")
testthat::expect_true(!is.unsorted(gear$GEAR))
gear = df %>%
talk_arrange("arrange by gear decreasing")
testthat::expect_true(all(diff(gear$GEAR) <= 0))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.