Dear R-helper,
How could I count only some variable was exist after running sample
(random) function.
For example,

> testx <- factor(c("Game","Paper","Internet","Time","Money"))
>    for(i in 1:2) {
+        x <- sample(testx,replace=TRUE)
+        print(x)
+    }
[1] Money    Money    Time     Internet Time    
Levels: Game Internet Money Paper Time
[1] Time  Money Game  Money Money
Levels: Game Internet Money Paper Time
> 

The result above Game, Internet, Money, and Time only exist and
"Paper" was missing.
Best, Sofyan

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to