invinteraction: Split an interaction'ed factor back into seperate variables

Description Usage Arguments Value Changes Author(s) References See Also Examples

View source: R/invinteraction.R

Description

Inverse of interaction

Usage

1
invinteraction(fac, ..., sep = ".")

Arguments

fac

the factor to split

...

optional, names for variables

sep

the seperator between levels

Value

a data.frame of factors

Changes

Refactored to process the levels vector, rather than entire factor vector.

Author(s)

42, Neal Fultz

References

http://stackoverflow.com/a/10521926/986793

See Also

interaction

Examples

1
2
3
4
5
6
7
8
9
f1 <- gl(2, 3)
f2 <- gl(3, 2)
invinteraction(f1:f2, sep=':') 

ppl <- interaction(
  eyes = as.factor(sample(colors(), 10)),
  hair = as.factor(sample(colors(), 10))
  )
str(invinteraction(ppl, "eyes", "hair"))

stackoverflow documentation built on Jan. 10, 2020, 9:07 a.m.