rangeString: Utility functions for table summaries

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Various auxiliary convenience functions, mostly for XLunivariate. Functions calculating simple statistics and returning the output in a formatted manner, making it easier for XLunivariate to embed them in spreadsheet cells.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
rangeString(x, digits = 1, sep = "-", na.rm = FALSE, ...)

iqrString(x, digits = 1, sep = "-", quantmeth = 7, na.rm = FALSE, ...)

roundmean(x, digits = 1, na.rm = FALSE, ...)

roundmedian(x, digits = 1, na.rm = FALSE, ...)

roundSD(x, digits = 1, na.rm = FALSE, ...)

emptee(x, ...)

Arguments

x

vector (usually numeric, but can be logical) on which statistics are to be calculated

digits

numeric: how many digits to round the output to?

sep

character: separating character for range- type functions.

na.rm

logical: should missing values be removed? (default FALSE) Passed onto the underlying functions

...

this is ignored by the functions, but enables the "mixing and matching" of extra parameters between functions called by XLunivariate, without triggering an error.

quantmeth

numeric: for functions calling quantile, the calculation method for the quantiles. Default is 7 to match the R default. Note that it is shrunk towards the median and hence biased, but typically with lower MSE. A very viable alternative is 6, the SAS/SPSS (and Stata?) default, which is unbiased. See the help on quantile for more details.

Details

This is a small collection of useful utilities called by XLunivariate. They return 1-2 summary statistics, in a format that will not require additional formatting and formula-manipulation in Excel.

For example, roundmedian returns the median rounded to the specified number of digits, while iqrString returns the 1st and 3rd quartiles, separated by at least one dash (default 3 dashes). XLunivariate can combine these functions' output to produce the formatted summary "median (Q1---Q3)" often used in research articles.

In particular, emptee returns an empty string, enabling the use of XLunivariate to produce only a single summary statistic per cell rather than a pair.

Value

The summary statistic(s), in the format specified via the arguments.

Author(s)

Assaf P. Oron <assaf.oron.at.seattlechildrens.org>

See Also

XLunivariate which is the main function calling these utilities.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
book2<-XLwriteOpen("chick2.xls") 
## Plain-vanilla
XLunivariate(book2,"weightByDiet",ChickWeight$weight,ChickWeight$Diet,
             title="Mean Weights by Diet",rowTitle="Diet")

## Replace mean/SD with median/range, put results beside previous
XLunivariate(book2,"weightByDiet",ChickWeight$weight,ChickWeight$Diet,
             title="Median Weights by Diet",rowTitle="Diet",col1=8,
             fun1=list(fun=roundmedian,name="Median"),fun2=list(fun=rangeString,name="range"))

### You can also do only one statistic... by "killing" one of the functions
XLunivariate(book2,"weightByAge",ChickWeight$weight,ChickWeight$Time,
             title="Mean Weights by Age",rowTitle="Age (Days)",seps=rep("",3),
             fun2=list(fun=emptee,name=""))
cat("Look for",paste(getwd(),"chick2.xls",sep='/'),"to see the results!\n")

table1xls documentation built on May 2, 2019, 5:54 a.m.