This looks like homework (which is off topic here per the Posting Guide). Also, please send your emails in plain text format to avoid us seeing your message differently than you do.
On July 4, 2018 3:21:34 PM PDT, Nelly Reduan <nell.r...@hotmail.fr> wrote: >Dear all, > >I would like to generate N random numbers with a given probability and >condition but I'm not sure how to do this. >For example, I have N = 20 and the vector from which to choose is >seq(0, 10, 1). I have tested: > >x <- sample(seq(0, 10, 1), 20, replace=TRUE, prob=rep(0.28, >times=length(seq(0, 10, 1)))) > >But I don�t know how to put the condition sum(x) <= max(seq(0, 10, 1)). >Many thanks for your time >Nell > > > [[alternative HTML version deleted]] -- Sent from my phone. Please excuse my brevity. ______________________________________________ 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.