[R] help in run if

Petr Savicky savicky at cs.cas.cz
Wed Feb 15 10:12:06 CET 2012


On Wed, Feb 15, 2012 at 12:31:54AM -0800, arunkumar1111 wrote:
> hi 
> 
> My data looks like
> 
> x=c(0,0,0,0,0)
> y=c(10,20,30,40,50)
> 
> i want to generate 5 random numbers  between x and y  keeping x values as
> min and y value as max using apply
> 
> it takes time when it is run using for

Hi.

A solution without a loop is 

  x + (y - x)*runif(length(x))

Hope this helps.

Petr Savicky.



More information about the R-help mailing list