Learn R Programming

sjPlot (version 2.3.3)

sjt.grpmean: Summary of grouped means as HTML table

Description

Computes mean, sd and se for each sub-group (indicated by var.grp) of var.cnt and prints the result as HTML table.

Usage

sjt.grpmean(var.cnt, var.grp, weight.by = NULL, value.labels = NULL,
  digits = 2, digits.summary = 3, CSS = NULL, encoding = NULL,
  file = NULL, use.viewer = TRUE, no.output = FALSE,
  remove.spaces = TRUE)

Arguments

var.cnt

Vector of counts, for which frequencies or means will be plotted or printed.

var.grp

Factor with the cross-classifying variable, where var.cnt is grouped into the categories represented by var.grp.

weight.by

Vector of weights that will be applied to weight all cases. Must be a vector of same length as the input vector. Default is NULL, so no weights are used.

value.labels

Character vector (or list of character vectors) with value labels of the supplied variables, which will be used to label variable values in the output.

digits

Numeric, amount of digits after decimal point when rounding estimates and values.

digits.summary

Amount of digits for summary statistics (Anova).

CSS

A list with user-defined style-sheet-definitions, according to the official CSS syntax. For more details, see this package-vignette, or 'Details' in sjt.frq.

encoding

String, indicating the charset encoding used for variable and value labels. Default is NULL, so encoding will be auto-detected depending on your platform (e.g., "UTF-8" for Unix and "Windows-1252" for Windows OS). Change encoding if specific chars are not properly displayed (e.g. German umlauts).

file

Destination file, if the output should be saved as file. If NULL (default), the output will be saved as temporary file and openend either in the IDE's viewer pane or the default web browser.

use.viewer

Logical, if TRUE, the HTML table is shown in the IDE's viewer pane. If FALSE or no viewer available, the HTML table is opened in a web browser.

no.output

Logical, if TRUE, the html-output is neither opened in a browser nor shown in the viewer pane and not even saved to file. This option is useful when the html output should be used in knitr documents. The html output can be accessed via the return value.

remove.spaces

Logical, if TRUE, leading spaces are removed from all lines in the final string that contains the html-data. Use this, if you want to remove parantheses for html-tags. The html-source may look less pretty, but it may help when exporting html-tables to office tools.

Value

Invisibly returns a list with

  • the data frame with the description information (df),

  • the web page style sheet (page.style),

  • the web page content (page.content),

  • the complete html-output (output.complete) and

  • the html-table with inlin-css for use with knitr (knitr)

for further use.

Details

This function performs a One-Way-Anova with var.cnt as dependent and var.grp as independent variable, by calling lm(var.cnt ~ as.factor(var.grp)), to get p-values for each sub-group and the complete "model". Thus, p-values indicate whether each group-mean is significantly different from the reference group (reference level of var.grp). Statistics like mean values are based on subsetted groups (i.e. var.cnt is divided into sub-groups indicated by var.grp).

Furthermore, see 'Details' in sjt.frq.

See Also

sjp.aov1

Examples

Run this code
# NOT RUN {
library(sjmisc)
data(efc)
sjt.grpmean(efc$c12hour, efc$e42dep)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab