Learn R Programming

Rlab (version 4.0)

means: Computes one-way and two-way means tables

Description

Calculates means for individual factors and two-way factor combinations. Any number of factors may be input and the indivdual factor means as well as all possible two-way means will be shown for each factor. Three-way, four-way, etc. means are not shown, even when more than 2 factors are given.

Usage

means(y, ..., dec = 3)

Arguments

y

Vector of responses whose means are shown.

Vectors of independent variables on which the responses' means are broken down.

dec

Number of decimal places to print.

See Also

mplot, mean

Examples

Run this code
# NOT RUN {
# Create a data set with two factors (age and gender)
race<-data.frame(c(1.02,.99,1.11,1.30,1.09,1.26,1.21,1.19,1.30,1.45,1.34,1.49),
                 c('M','M','M','M','M','M','F','F','F','F','F','F'),
                 c('under 50','under 50','under 50','over 50','over 50','over 50',
                   'under 50','under 50','under 50','over 50','over 50','over 50'))
names(race)<-c("time","gender","age")


# Show mean times broken by age, gender and age & gender
means(race$time, race$age, race$gender)
# }

Run the code above in your browser using DataLab