Thanks for your help. How about if I count all. This below I have fixed my code which used table. I need the result:
Game Internet Money Paper Time 4 1 1 4 0 Regards, Sofyan > testx <- factor(c("Game","Paper","Internet","Time","Money")) > for(i in 1:2) { + x <- sample(testx,replace=TRUE) + print(x) + print(table(x)) + } [1] Game Paper Game Paper Paper Levels: Game Internet Money Paper Time x Game Internet Money Paper Time 2 0 0 3 0 [1] Game Game Internet Paper Money Levels: Game Internet Money Paper Time x Game Internet Money Paper Time 2 1 1 1 0 > On 6/1/05, TEMPL Matthias <[EMAIL PROTECTED]> wrote: > > Dear R-helper, > > How could I count only some variable was exist after running sample > > (random) function. > > Or is this what you want? > > Tab <- table(sample(testx, replace=TRUE)) > Tab[ Tab > 0 ] > ______________________________________________ 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