View source: R/stats-getStats.R
getStatsData | R Documentation |
This set of statistics can be passed directly to the stats
parameter
of the package functions.
By default, statistics are extracted based on the variable(s) type
and formatted with the default rules implemented in the package.
getStatsData(
data,
var = NULL,
type = "default",
extra = NULL,
args = NULL,
...
)
data |
Data.frame with dataset to consider for the summary table. |
var |
(optional, recommended for continuous variable)
Character vector with variable(s) of data, to
compute statistics on. |
type |
Character vector with type of statistics to extract, among:
To specify statistics for a continuous (numeric) or categorical variable separately, this vector can be named with: 'cont' or 'cat' respectively (elements not named are used for both continuous and categorical variables). |
extra |
List with extra statistics to include, or function to apply on each
|
args |
(optional) Named list with extra arguments for
|
... |
Extra parameters passed to the |
List with statistics to compute, named by var
Laure Cougnaud
getStats
# default set of statistics (depending if the variable is continuous or categorical)
exampleData <- data.frame(
USUBJID = 1 : 4,
WEIGHT = c(67, 78, 83, 61),
SEX = c("F", "M", "M", "F"),
stringsAsFactors = FALSE
)
getStatsData(data = exampleData, var = c("WEIGHT", "SEX"))
# all set of statistics (depending if the variable is continuous or categorical)
getStatsData(data = exampleData, var = c("WEIGHT", "SEX"), type = "all")
# custom set of statistics for all variables
getStatsData(data = exampleData, var = c("WEIGHT", "SEX"), type = c("n", "%"))
# custom set of statistics, depending on the type of the variable
getStatsData(data = exampleData, var = c("WEIGHT", "SEX"),
type = c(cont = "median (range)", cont = "mean (se)", cat = "n (%)"),
args = list(cat = list(includeName = FALSE))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.