Try

foo <- function(n){
 x <- runif(n)
 x * 100 / sum(x)
}
foo(4)

HTH,
Jorge.-


On Mon, Jan 9, 2012 at 10:06 AM, arunkumar1111 <> wrote:

> Hi
> I want to generate 4 random number which sum up to 100 always
>
> Please help
>
>
> -----
> Thanks in Advance
>        Arun
> --
> View this message in context:
> http://r.789695.n4.nabble.com/runif-with-condition-tp4278704p4278704.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]

