Learn R Programming

psytabs (version 1.0)

meanTable: Mean table.

Description

Produces a 2- or 1-dimensional table of means (and a measure of variation) regarding a variable and one or two factors.

Usage

meanTable(value, ver.factor, hor.factor = NA, variation="se")

Arguments

value
numeric vector, for which the table should be created.
ver.factor
factor constituting the rows of the table.
hor.factor
factor constituting the columns of the table.
variation
can be either "se" or "sd". variation="se" computes the standard errors and variation="sd" the standard deviation.

Value

A mean table.

Examples

Run this code
data(mydata)
mydata.sumscore <- rowSums(mydata[,c("item1", "item2", "item3", "item4")])
meanTable(mydata.sumscore, mydata$age_group7)
meanTable(mydata.sumscore, mydata$age_group7, mydata$sex)
meanTable(mydata.sumscore, mydata$sex, mydata$age_group7)
(tab <- meanTable(mydata.sumscore, mydata$age_group7, mydata$sex, variation="sd"))

#saveTable(tab, "meanTable.rtf")

Run the code above in your browser using DataLab