Description Usage Arguments Value Author(s) See Also Examples

The function produces summary tables for factor variables.
The obtained tables can be used directly in R, with LaTeX
and HTML (by using the `xtable`

function) or Markdown
(e.g. by using the function `kable`

).

1 2 3 4 5 6 7 8 9 | ```
summarize_factor(data,
variables = names(data), variable.labels = labels, labels = NULL,
group = NULL, test = !is.null(group), colnames = NULL,
digits = 3, digits.pval = 3, smallest.pval = 0.001,
sep = TRUE, sanitize = TRUE, drop = TRUE,
show.NAs = any(is.na(data[, variables])),
## additional specific arguments
percent = TRUE, cumulative = FALSE,
na.lab = "<Missing>", ...)
``` |

`data` |
data set to be used. |

`variables` |
variables that should be included in the table.
For details see |

`variable.labels, labels` |
labels for the variables.
For details see |

`group` |
character specifying a grouping factor.
For details see |

`test` |
logical or charachter specifying test for group differences.
For details see |

`colnames` |
a vector of character strings of appropriate length.
For details see |

`digits` |
number of digits to round to (only used for fractions). Per default all values are rounded to three digits. |

`digits.pval` |
number of significant digits used for p-values. |

`smallest.pval` |
determines the smallest p-value to be printed exactly.
For details see |

`sep` |
logical (default: |

`sanitize` |
logical (default: |

`drop` |
logical (default: |

`show.NAs` |
logical. Determines if NAs are displayed as a separate category for
each factor variable with missings. If |

`percent` |
logical. Should the fractions be given as percent values? Otherwise, fractions are given as decimal numbers. |

`cumulative` |
logical. Should cumulative fractions be displayed? |

`na.lab` |
label for missing values (default: |

`...` |
additional arguments. Currently not used. |

A special `data.frame`

with additional class `summary`

containing the computed statistics is returned from function
`summarize`

. Addtional attributes required for the
`xtable.summary`

or `print.xtable.summary`

function are contained as attributes. These are extracted using the
function `get_option`

.

Benjamin Hofner

For details see `link{summarize}`

and `link{summarize_factor}`

.

Conversion to LaTeX tables can be done using
`xtable.summary`

and `print.xtable.summary`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ```
## Example requires package nlme to be installed and loaded
if (require("nlme")) {
## Use dataset Orthodont
data(Orthodont, package = "nlme")
## Get summary for continuous variables
summarize(Orthodont, type = "factor")
## Reorder data for table:
summarize(Orthodont, variables = c("Sex", "Subject"), type = "factor")
## What happens in the display if we introduce some missing values:
set.seed(1907)
Orthodont$Sex[sample(nrow(Orthodont), 20)] <- NA
summarize(Orthodont, type = "factor")
summarize(Orthodont, variables = "Sex", type = "factor")
## do not show statistics on missing values
summarize(Orthodont, variables = "Sex", show.NAs = FALSE, type = "factor")
}
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.