File: jmfuns.rda
desc produces descriptive statistics for a sample. There can be multiple measurements on the sample, and the sample can be stratified by one or more factors.
Warning: The first argument of desc is .... Therefore all other arguments must be
entered with the full argument name,
e.g., desc(var1, var2, miss =
"varwise") will produce an error ("miss" should be written as
"miss.handling").
desc(
...,
by = NULL,
stats = c( "all", "median", "mean", "sd", "var", "se.mean", "min", "max", "n.total", "n.valid", "n.miss", "n.valid.lw", "n.miss.lw")[c(3, 4, 7, 8, 11, 12)],
varNames = nameArgs(...)
miss.handling = c("listwise", "varwise", "none")[1],
ord.byvar = TRUE,
transpose = FALSE )
The possible statistics to be reported are: mean ("mean"), median ("median"), minimum ("min"), maximum ("max"), standard deviation ("sd"), standard error of the mean ("se.mean"), variance ("var"), listwise valid cases ("nvalid.lw"), listwise missing ("nmis.lw"), variablewise valid cases ("nvalid"), variablewise missing ("nmis")
The default stats argument (all) requests all of these statistics. Individual statistics can be requested with an appropriate character vector, e.g., c("mean", "median") requests only the mean and median. By default, the number of listwise valid and missing cases are always reported.
ARGUMENTS:
... One or more quantitative variables, all of the same length. Statistics will be reported for these variables.
by A factor, matrix, list, or dataframe. The by argument will be converted to a list of factors if it is not already a list of factors. Statistics are computed for each subsample defined by the combinations of these factors. If by = NULL (default), then statistics are computed for the quantitative variables without any stratification.
stats Names of the statistics to be reported. The possible values of stats are: "all", "median", "mean", "sd", "var", "se.mean", "min", "max", "n.total", "n.valid", "n.miss", "n.valid.lw", "n.miss.lw". If "n.valid" or "n.miss" are selected, the number of valid or missing cases are reported for each variable and stratum without regard to any other variables. If "n.valid.lw" or "n.miss.lw" are selected, the number of valid or missing cases are reported after removing any case that is missing on any of the variables (so-called "listwise" deletion of missing values). The default selection of statistics is: "mean", "sd", "min", "max", "n.valid.lw", "n.miss.lw". Setting stats to "all" selects all of these statistics. A future version of desc will allow the user to request statistics that are computed by user-designated functions, but this functionality has not been implemented.
miss.handling If miss.handling = "listwise" (default), then all cases that are missing on any of the quantitative variables or factors designated by by are removed from the data prior to computing statistics. If miss.handling = "varwise", then cases are removed if they are missing on the specific variable whose statistics are being computed. If miss.handling = "none", then no missing values are removed. Note that many of the statistics, e.g., mean or sd, will return NA if missing values are present in the data.
ord.byvar Has no effect if by is null. If by is non-null, ord.byvar = TRUE, and there are 2 or more variables to be described, then the output has one row per stratum combination and all statistics for a variable are grouped together as consecutive columns. If by is non-null, ord.byvar = FALSE and there are 2 or more variables to be described, all statistics of the same type, e.g., all means or all sd's, are grouped together as consecutive columns. If by is null, then each column represents a different variable, and each row presents a different statistic, e.g, row 1 might be the medians, row 2 might be the means, etc.
transpose If transpose = TRUE, then the output is transposed (strata in columns, one row per stat). The default is transpose = FALSE (strata in rows, one column per stat).
VALUE
desc prints the requested statistics and outputs the statistics as an nStats x nVars matrix, where nStats is the number of statistics requested with the stats argument, and nVars is the number of quantitative variables specified by the ... argument.
#-------------- The 'doc' bookmark highlights all of the documentation but not the function skeleton at the top of the file. Use rdocToString macro to convert documentation to an R string variable. Bkmk docStringsLoc = <\#PATH\docStrings\> ---------------
Format for this html document: Page Size = Tabloid: 11" x 17". Note that Tabloid page size is available if Adobe PDF is set as the default printer, but not if the default printer is a physical printer that prints 8.5" x 11" standard paper. Table widths = 9.5"