Learn R Programming

sjmisc (version 1.0.2)

is_crossed: Check whether two factors are crossed

Description

This function checks whether two factors are crossed, i.e. if each level of one factor occurs in combination with each level of the other factor.

Usage

is_crossed(f1, f2)

Arguments

f1
a numeric vector or factor.
f2
a numeric vector or factor.

Value

  • Logical, TRUE if factors are crossed, FALSE otherwise.

References

Grace, K. The Difference Between Crossed and Nested Factors. http://www.theanalysisfactor.com/the-difference-between-crossed-and-nested-factors/{(web)}

See Also

is_nested

Examples

Run this code
# crossed factors, each category of
# x appears in each category of y
x <- c(1,4,3,2,3,2,1,4)
y <- c(1,1,1,2,2,1,2,2)
# show distribution
table(x, y)
# check if crossed
is_crossed(x, y)

# not crossed factors
x <- c(1,4,3,2,3,2,1,4)
y <- c(1,1,1,2,1,1,2,2)
# show distribution
table(x, y)
# check if crossed
is_crossed(x, y)

Run the code above in your browser using DataLab