[R] Interaction versus combinations

From: Alex van der Spek <doorz_at_xs4all.nl>
Date: Thu, 03 Jun 2010 21:08:11 +0200


I can get the interactions between factors like this:

> idx=c(1,3,6,9)
> jdx=idx
> levels(interaction(idx,jdx,lex.order=TRUE))
  [1] "1.1" "1.3" "1.6" "1.9" "3.1" "3.3" "3.6" "3.9" "6.1" "6.3" "6.6" "6.9"
[13] "9.1" "9.3" "9.6" "9.9"

This list contains all possible interactions. Whereas I need only the combinations, e.g 4 over 2 = 6 total being

"1.3 " "1.6" "1.9" "3.6" "3.9" "6.9"

I have been unable to find how to get the combinations. Of course with some string manipulations this can be done for this toy example. There should be something in R to make this easy?

Thanks in advance
Alex van der Spek



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 03 Jun 2010 - 19:15:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Jun 2010 - 19:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive