| desc_cont | R Documentation |
Summarize continuous data and
handle output format.
desc_cont(
.data,
vc,
format = "median (q1-q3) [min-max]",
digits = 1,
export_raw_values = FALSE
)
.data |
A data.frame, where |
vc |
A character vector, list of column names. Should only contain continuous variables |
format |
A character string. How would you like the output? See details. |
digits |
A numeric. How many digits? This argument calls internal formatting function |
export_raw_values |
A logical. Should the raw values be exported? |
Many other packages provide tools to summarize data. This one is just
the package author's favorite.
This makes it much easier to map to nice labeling thereafter.
The format argument shows the output of the function. You can change square
and round brackets, spaces, separators... Important format
inputs are
median the median value
q1 the first quartile
q3 the third quartile
min the minimum value
max the maximum value
The analogous for categorical variables is desc_facvar().
A data.frame with columns
var the variable name
level NA, it is provided to have a consistent output
with desc_facvar()
value the formatted value with possibly the median,
interquartile range, and range (see details)
n_avail the number of cases with available data for this
variable.
desc_facvar()
df <-
data.frame(
smoke_status = c("smoker", "non-smoker",
"smoker", "smoker",
"smoker", "smoker",
"non-smoker"
),
age = c(60, 50, 56, 49, 75, 69, 85),
bmi = c(18, 30, 25, 22, 23, 21, 22)
)
# Use default formatting
desc_cont(.data = df, vc = c("age", "bmi"))
# Use custom formatting
desc_cont(.data = df,
vc = c("age", "bmi"),
format = "median (q1;q3)"
)
# You might want to export raw values, to run plotting or
# other formatting functions
desc_cont(.data = df, vc = c("age", "bmi"),
export_raw_values = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.