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 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Wed, Sep 16, 2015 at 10:11 AM, thanoon younis <thanoon.youni...@gmail.com> 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 > decimals like 1.244, 2.342,4,321 and so on ... My question how can i > generate a vector and also a matrix with orered categorical variables and > without decimals just 1,2,3 ,4 ,1,2,3,4, .... > > Many thanks in advance > > > > > > -- > Thanoon Y. Thanoon > PhD Candidate > Department of Mathematical Sciences > Faculty of Science > University Technology Malaysia, UTM > E.Mail: thanoon.youni...@gmail.com > E.Mail: dawn_praye...@yahoo.com > Facebook:Thanoon Younis AL-Shakerchy > Twitter: Thanoon Alshakerchy > H.P:00601127550205 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.