[R] Re: Which variable exist after random

Sofyan Iyan sofyan.iyan at gmail.com
Thu Jun 2 11:50:03 CEST 2005


Dear R-help again,
I have a result something like this,
[[1]]
[1] "Game"     "Internet"

[[2]]
[1] "Game"     "Internet"

[[3]]
[1] "Game"    "Time"

How could I make the result above like,

[1] "Game","Internet","Time"

Regards, Sofyan

On 6/1/05, Sofyan Iyan <sofyan.iyan at gmail.com> wrote:
> 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
>




More information about the R-help mailing list