descvar {mcradds} | R Documentation |
Summarize Descriptive Statistics
Description
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.
Usage
descvar(
data,
var,
bygroup,
stats = getOption("mcradds.stats.default"),
autodecimal = TRUE,
decimal = 1,
addtot = FALSE,
.perctype = 2
)
Arguments
data |
( |
var |
( |
bygroup |
( |
stats |
( |
autodecimal |
( |
decimal |
( |
addtot |
( |
.perctype |
( |
Value
A object Desc
contains an intermediate data with long form for
post-processing and final data with wide form for presentation.
Note
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()
.
Examples
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
)