Re: [R] Sample function in R

2012-02-12 Thread Petr Savicky
On Sun, Feb 12, 2012 at 01:57:18PM -0500, SUPAKORN LAOHAPITAKVORN wrote: > This is what I got: > > > sessionInfo() > R version 2.14.1 (2011-12-22) > Platform: x86_64-pc-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 > [2] LC_CTYPE=English_United States.1252 > [3] LC_

Re: [R] Sample function in R

2012-02-12 Thread Etienne B. Racine
Supakorn, Try: rm(sample) #then sample(x) Etienne 2012/2/12 SUPAKORN LAOHAPITAKVORN > This is what I got: > > > sessionInfo() > R version 2.14.1 (2011-12-22) > Platform: x86_64-pc-mingw32/x64 (64-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 > [2] LC_CTYPE=English_United States.

Re: [R] Sample function in R

2012-02-12 Thread SUPAKORN LAOHAPITAKVORN
This is what I got: > sessionInfo() R version 2.14.1 (2011-12-22) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252

Re: [R] Sample function in R

2012-02-12 Thread Jorge I Velez
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

Re: [R] Sample function in R

2012-02-12 Thread R. Michael Weylandt
sessionInfo()? Can you replicate this behavior in a R --vanilla session? This seems very odd and I presume you've overwritten sample() somewhere in your workspace. Michael On Sun, Feb 12, 2012 at 12:52 PM, SUPAKORN LAOHAPITAKVORN wrote: > Hi, > Can anyone help me with the sample () in R? > > If

[R] Sample function in R

2012-02-12 Thread SUPAKORN LAOHAPITAKVORN
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

Re: [R] Sample function in R???

2011-02-19 Thread Peter Ehlers
On 2011-02-19 10:32, Hongwei Dong wrote: Hi, R users, I'm wondering if there a way in R I can select cases based on a probability vector. if a case is selected, that case is marked as 1, otherwise, 0. For example: x<-12:18 y<-1:7 sample(x,2,replace=FALSE,y) I got: [1] 15 17 What I want to s

[R] Sample function in R???

2011-02-19 Thread Hongwei Dong
Hi, R users, I'm wondering if there a way in R I can select cases based on a probability vector. if a case is selected, that case is marked as 1, otherwise, 0. For example: x<-12:18 y<-1:7 sample(x,2,replace=FALSE,y) I got: [1] 15 17 What I want to see is: [1] 0 0 0 1 0 1 0 Thanks. Gary