descvar | R Documentation |
Create a summary table with a set of descriptive statistics for one or more variables by one group, as well as a total column if necessary.
descvar(
data,
var,
bygroup,
stats = getOption("mcradds.stats.default"),
autodecimal = TRUE,
decimal = 1,
addtot = FALSE,
.perctype = 2
)
data |
( |
var |
( |
bygroup |
( |
stats |
( |
autodecimal |
( |
decimal |
( |
addtot |
( |
.perctype |
( |
A object Desc
contains an intermediate data with long form for
post-processing and final data with wide form for presentation.
The decimal precision is based on two aspects, one is the original precision
from the variable or the decimal
argument, and the second is the common use that
has been defined in getOption("mcradds.precision.default")
. So if you want to
change the second decimal precision, you can alter it manually with option()
.
data(adsl_sub)
# Compute the default statistics of AGE by TRTP group
adsl_sub %>%
descvar(
var = "AGE",
bygroup = "TRTP"
)
# Compute the specific statistics of BMI by TRTP group, adding total column
adsl_sub %>%
descvar(
var = "BMIBL",
bygroup = "TRTP",
stats = c("N", "MEANSD", "MEDIAN", "RANGE", "IQR"),
addtot = TRUE
)
# Set extra decimal to define precision
adsl_sub %>%
descvar(
var = "BMIBL",
bygroup = "TRTP",
stats = c("N", "MEANSD", "MEDIAN", "RANGE", "IQR"),
autodecimal = FALSE,
decimal = 2,
addtot = TRUE
)
# Set multiple variables together
adsl_sub %>%
descvar(
var = c("AGE", "BMIBL", "HEIGHTBL"),
bygroup = "TRTP",
stats = c("N", "MEANSD", "MEDIAN", "RANGE", "IQR"),
autodecimal = TRUE,
addtot = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.