Learn R Programming

s20x (version 3.1-40)

crossFactors: Crossed Factors

Description

Computes a factor that has a level for each combination of the factors 'fac1' and 'fac2'.

Usage

crossFactors(x, fac2 = NULL, ...)

# S3 method for default crossFactors(x, fac2 = NULL, ...)

# S3 method for formula crossFactors(formula, fac2 = NULL, data = NULL, ...)

Value

Returns a vector containing the factor which represents the interaction of the given factors.

Arguments

x

the name of the first factor or a formula in the form ~ fac1 * fac2

fac2

the name of the second factor - ignored if x is a formula.

...

Optional arguments

formula

a formula in the form ~ fac1 * fac2

data

an optional data frame in which to evaluate the formula

Methods (by class)

  • crossFactors(default): Crossed Factors

  • crossFactors(formula): Crossed Factors

See Also

Examples

Run this code

## arousal data:
data(arousal.df)
gender.picture = crossFactors(arousal.df$gender, arousal.df$picture)
gender.picture

## arousal data:
data(arousal.df)
gender.picture = crossFactors(~ gender * picture, data = arousal.df)
gender.picture


Run the code above in your browser using DataLab