means | R Documentation |
This function calculates summary statistics on a data frame. It is intended to use to calculate a standard number of descriptive statistics which are defined in the packs argument
means(dfrm, variable, by, total = NULL, pack = 1, dig = 2, alpha = 0.1)
dfrm |
the data frame to calculate the statistics on |
variable |
character with the variable within the data frame for which the statistics should be calculated |
by |
character vector of variable(s) within the data frame to stratify the statistics on |
total |
character vector of variable(s) within the data frame to calculate totals on |
pack |
numeric indicating number of the pack or name of the function with different descriptive statistics (see details) |
dig |
the number of digits to use for output statistics (except for N which is always displayed as integer) |
alpha |
the alpha in case the statistics pack calculates confidence limits |
The function calculates multiple statistics of a data frame that can be stratified. Furthermore, the statistics for a total can also be generated. Currently the function has the possibility to calculate 3 different sets of statistics which are commonly used within the field of clinical data analysis:
N, Mean, Median, SD, Min, Max
Ntot, N, Nmiss, Mean, Median, SD, Min, Max, CLM (different N values are given to identify the number of missing values)
N, Mean (SD), Median, Range (Both Mean (SD) and Range are concatenated to generate a dense overview of statistics)
All statistics are calculated on using na.rm set to TRUE, meaning that NA values are removed before calculating the statistics. A predefined set of statistics is chosen and not the possibility to implement user defined descriptive statistics. The reason for this is that there are many other (more simple) options to do this within R.
The function returns a dataframe with calculated descriptive statistics
data(Indometh)
means(Indometh,"conc","time",total="time",pack=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.