A.level <- factor( rep(1:R, apply(K,1,sum)))
B.level <- factor( unlist( apply(K,1,function(t) rep( 1:C, t )) ) )
--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-g...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
הי טל,
סליחה - הנה קוד self contained:
R <- 4 # number of "row" factors
C <- 3 # number of "column" factors
K <- matrix( sample(c(1,2),R*C,replace=T), nrow=R ) # K_ij is the number of observations in the ij cell
A.level <- factor( rep(1:R, apply(K,1,sum)) )
B.level <- factor( unlist( apply(K,1,function(t) rep( 1:C, t )) ) )
cbind(A.leve,B.level) # this is the final result I'm looking for
תודה!
אסף