Hi,

The following is what I get:

> x =1:12
> x
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
> sample(x)
 [1]  9  6 12  5  3  4  1 11  8  7 10  2
> sample(x, size = 2)
[1] 9 4

What's the output of sessionInfo() and ls() ?   Perhaps you have a
different "sample" function in your workspace?

HTH,
Jorge.-


On Sun, Feb 12, 2012 at 12:52 PM, SUPAKORN LAOHAPITAKVORN <> wrote:

> Hi,
> Can anyone help me with the sample () in R?
>
> If I sample from x, I should get one integer.  Can anyone tell me what's
> wrong here?
> > x =1:12
> > sample(x)
> [1] 6.5
>
> And, I cannot get the sample with size = 2
> > sample(x, size = 2)
> Error in sample(x, size = 2) : unused argument(s) (size = 2)
> > sample(x, 2)
> [1] 54.16667
>
> Thank you in advance
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org 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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to