tb | R Documentation |
Make a tidy dataset out of freq() or descr() outputs
tb(
x,
order = 1,
drop.var.col = FALSE,
recalculate = TRUE,
fct.to.chr = FALSE,
...
)
x |
a |
order |
Integer. Useful for grouped results produced with
|
drop.var.col |
Logical. For |
recalculate |
Logical. TRUE by default. For grouped
|
fct.to.chr |
Logical. When grouped objects
are created with |
... |
For internal use only. |
stby
, which is based on and by
, initially make the first
variable vary, keeping the other(s) constant. On the other hand,
group_by
initially keeps the first grouping variable(s) constant,
making the last one vary. This will impact the ordering of the rows (and
as a result, the cumulative percent columns, if present).
Also, keep in mind that while group_by
shows NA
groups by
default, useNA = TRUE
must be used to achieve the same
results with stby
.
A tibble
which is constructed following the
tidy principles.
tb(freq(iris$Species))
tb(descr(iris, stats = "common"))
data("tobacco")
tb(stby(tobacco, tobacco$gender, descr, stats = "fivenum",check.nas = FALSE),
order=3)
tb(stby(tobacco, tobacco$gender, descr, stats = "common", useNA = TRUE))
# Compare stby() and group_by() groups' ordering
tb(with(tobacco, stby(diseased, list(gender, smoker), freq, useNA = TRUE)))
## Not run:
tobacco |> dplyr::group_by(gender, smoker) |> freq(diseased) |> tb()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.