Re: [R] show unique combination of two factor

2006-11-24 Thread Chuck Cleland
Aimin Yan wrote:
 p factor have 5 levels
 aa factor have 19 levels.
 totally it should have 95 combinations.
 but I just find there are 92 combinations.
 Does anyone know how to code to find what combinations are missed?

  Here is an example with fewer factor levels of one way you might do this:

df - data.frame(p = rep(c(A,B,C,D), each=10),
 aa = rep(c(Yes,No), 20))

df$aa - replace(df$aa, df$p == D, No)

table(df)
   aa
p   No Yes
  A  5   5
  B  5   5
  C  5   5
  D 10   0

names(which(with(df, table(interaction(p, aa))) == 0))
[1] D.Yes

 Thanks,
 
 Aimin
 
 __
 R-help@stat.math.ethz.ch 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@stat.math.ethz.ch 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.


Re: [R] show unique combination of two factor

2006-11-24 Thread Michael Dewey
At 22:02 23/11/2006, Aimin Yan wrote:
p factor have 5 levels
aa factor have 19 levels.
totally it should have 95 combinations.
but I just find there are 92 combinations.
Does anyone know how to code to find what combinations are missed?

Does
which(table(p,aa) == 0, arr.ind=TRUE)
do what you wanted.



Thanks,

Aimin



Michael Dewey
http://www.aghmed.fsnet.co.uk

__
R-help@stat.math.ethz.ch 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.


[R] show unique combination of two factor

2006-11-23 Thread Aimin Yan
p factor have 5 levels
aa factor have 19 levels.
totally it should have 95 combinations.
but I just find there are 92 combinations.
Does anyone know how to code to find what combinations are missed?

Thanks,

Aimin

__
R-help@stat.math.ethz.ch 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.