Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Marc Schwartz
> On Sep 16, 2015, at 3:40 PM, Bert Gunter wrote: > > Nope. Take it back. I stand uncorrected. > >> system.time(z <-sample(1:10,1e6, rep=TRUE)) > user system elapsed > 0.045 0.001 0.047 > >> system.time(z <-sample.int(10,1e6,rep=TRUE)) > user system elapsed > 0.012 0.000 0.013

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Bert Gunter
Nope. Take it back. I stand uncorrected. > system.time(z <-sample(1:10,1e6, rep=TRUE)) user system elapsed 0.045 0.001 0.047 > system.time(z <-sample.int(10,1e6,rep=TRUE)) user system elapsed 0.012 0.000 0.013 sample() has to do subscripting in the general case; sample.int d

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Bert Gunter
Yes. Thanks Marc. I stand corrected. -- Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Wed, Sep 16, 2015 at 1:28 PM, Marc Schwartz wrote: > >> On Sep 16, 2015, at 1:06 PM, Bert Gunter wrote: >> >> Yikes!

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Marc Schwartz
> On Sep 16, 2015, at 1:06 PM, Bert Gunter wrote: > > Yikes! The uniform distribution is a **continuous** distribution over > an interval. You seem to want to sample over a discrete distribution. > See ?sample for that, as in: > > sample(1:4,100,rep=TRUE) > > ## or for this special case and fa

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Bert Gunter
Yikes! The uniform distribution is a **continuous** distribution over an interval. You seem to want to sample over a discrete distribution. See ?sample for that, as in: sample(1:4,100,rep=TRUE) ## or for this special case and faster sample.int(4,size=100,rep=TRUE) Cheers, Bert Bert Gunter "Da

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Marc Schwartz
> On Sep 16, 2015, at 12:11 PM, thanoon younis > wrote: > > Dear R- users > > I want to generate ordered categorical variable vector with 200x1 dimension > and from 1 to 4 categories and i tried with this code > > Q1=runif(200,1,4) the results are not just 1 ,2 3,4, but the results with > dec

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread David L Carlson
TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of thanoon younis Sent: Wednesday, September 16, 2015 12:11 PM To: r-help@r-project.org Subject: [R] generate ordered categorical variable in R Dear R- users I want to generate ordered categorical va

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Rui Barradas
Hello, Try ?sample. Hope this helps, Rui Barradas Em 16-09-2015 18:11, thanoon younis escreveu: Dear R- users I want to generate ordered categorical variable vector with 200x1 dimension and from 1 to 4 categories and i tried with this code Q1=runif(200,1,4) the results are not just 1 ,2 3,4

Re: [R] generate ordered categorical variable in R

2015-09-16 Thread Michael Dewey
If I understand correctly ?sample On 16/09/2015 18:11, thanoon younis wrote: Dear R- users I want to generate ordered categorical variable vector with 200x1 dimension and from 1 to 4 categories and i tried with this code Q1=runif(200,1,4) the results are not just 1 ,2 3,4, but the results wi

[R] generate ordered categorical variable in R

2015-09-16 Thread thanoon younis
Dear R- users I want to generate ordered categorical variable vector with 200x1 dimension and from 1 to 4 categories and i tried with this code Q1=runif(200,1,4) the results are not just 1 ,2 3,4, but the results with decimals like 1.244, 2.342,4,321 and so on ... My question how can i generate a