Description Usage Arguments Details Value Author(s) See Also Examples
Calculates a one-way contingency table in counts and percents, exports a formatted output to a spreadsheet, and saves the file.
1 2 3 4 5 | XLoneWay(wb, sheet, rowvar, table1mode = FALSE, title = NULL,
rowTitle = "Value", rowNames = NULL, colNames = NULL, ord = NULL,
row1 = 1, col1 = 1, digits = ifelse(length(rowvar) >= 500, 1, 0),
combine = TRUE, useNA = "ifany", testname = NULL, testBelow = FALSE,
margins = TRUE, ..., purge = FALSE, pround = 3)
|
wb |
a |
sheet |
numeric or character: a worksheet name (character) or position (numeric) within |
rowvar |
vector: the categorical variable (logical, numeric, character, factor, etc.) to be tabulated. |
table1mode |
logical: is the function called from |
title |
character: an optional overall title to the table. Default ( |
rowTitle |
character: the title to be placed above the row name column (default empty string) |
rowNames |
character: vector of row names. Default behavior ( |
colNames |
dummy argument for compatibility with calls from |
ord |
numeric vector specifying row-index order in the produced table. Default ( |
row1, col1 |
numeric: the first row and column occupied by the table (title included if relevant). |
digits |
numeric: how many digits (after the decimal point) to show in the percents? Defaults to 1 if n>=500, 0 otherwise. |
combine |
logical: should counts and percents be combined to the popular |
useNA |
How to handle missing values. Passed on to |
testname |
string, the name of a function to run a significance test on the table. Default |
testBelow |
logical, should test p-value be placed right below the table? Default |
margins |
logical: should margins with totals be returned? Default |
... |
additional arguments as needed, to pass on to |
purge |
logical should |
pround |
number of significant digits in test p-value representation. Default 3. |
This function performs a one-way contingency table, also calculating the distribution in percents.
The table is then exported to worksheet sheet
in workbook wb
, either using the format "Count(percent)"
(if combine=TRUE
), or as two separate columns in the same table.
See the XLtwoWay
help page, for behavior regarding new-sheet creation, overwriting, etc.
The function returns invisibly, after writing the data into sheet
and saving the file.
Assaf P. Oron <assaf.oron.at.seattlechildrens.org>
If interested in other descriptive summaries, see XLunivariate
. For two-way contingency tables, see XLtwoWay
.
1 2 3 4 5 6 7 | book1<-XLwriteOpen("chick1.xls")
XLoneWay(book1,"Diets",ChickWeight$Diet)
### Now in separate columns, and with a title - note it shifts the table down.
### Also adding a Chi-Square goodness of fit (GoF) test vs. a 2:1:1:1 allocation
XLoneWay(book1,"Diets",ChickWeight$Diet,combine=FALSE,row1=10,
rowTitle="Diet",title="Counts by Diet:",testname='chisq.test',p=c(2,1,1,1)/5)
cat("Look for",paste(getwd(),"chick1.xls",sep='/'),"to see the results!\n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.