Kabeli,

Try sample (see ?sample) and set the prob argument to have larger probabilities for bigger numbers:

set.seed(5)
x = sample(1:10, 100, prob = c(.03, .03, .04, .05, .05, .05, .15, .2, .2, .2), replace=TRUE)

>table(x)

x
1  2  3  4  5  6  7  8  9 10
4  3  7  5  9  3 10 18 24 17

Does that get you what you need?

Greg

KABELI MEFANE wrote:
R-list
I am sorry for asking this stupid question, but i have been running in circles. I want to randomly generate a scaling point of between 1 and 10, for say hundred entries, where the first 10% percent is has rates between 2 and 7, the next 15% 3 and 7, 20% between 3 and 9, 20% between 3 and 10, 35% between 5 and 10. The problem is that i can only generate the usual 100 using runif function > y<-c(ceiling(10*runif(100)))
y
  [1] 10  8  5  2  4  1  6  7  1  6  8  8  8  9  7  7  8  8  2  7  3 10  1  7  1
 [26] 10  4  8  8  8  9  3  7  8  4  6  7  2  3  1  9  8  2  6  7  4  8  8  9  7
 [51]  6  5  4  1  8  7  9  8 10  5  3  7  5  5  4  4  7  4 10  4  9  1  5 10 10
 [76]  5  5 10  7  3  4  4  9 10  6  2  6  6  6  3  8  2  2  4  4 10  6  9  4  3

I just want to try to avoid small numbers as much as possible. I am open to 
suggestions, please please please.
Kabeli


[[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.

--
Greg Hirson
ghir...@ucdavis.edu

Graduate Student
Agricultural and Environmental Chemistry

1106 Robert Mondavi Institute North
One Shields Avenue
Davis, CA 95616

______________________________________________
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