[R] random between two values

2009-08-06 Thread damien landais
Hi,
I would obtain a random value between two (for example between 40.15 and 56.58 
I would have only one value).
I'm looking for a package/a function which could do this.
Could anybody help me please?

Cordialement
Damien Landais

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


Re: [R] random between two values

2009-08-06 Thread Alfredo
sample(c(a,b))[1]

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of damien landais
Sent: Thursday, August 06, 2009 11:02 AM
To: R-help@r-project.org
Subject: [R] random between two values

Hi,
I would obtain a random value between two (for example between 40.15 and
56.58 I would have only one value).
I'm looking for a package/a function which could do this.
Could anybody help me please?

Cordialement
Damien Landais

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

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


Re: [R] random between two values

2009-08-06 Thread Sarah Goslee
That's pretty straightforward to do - here's a simple function. The
exact behavior
at the edges is left as an exercise. :)

rbound - function(rmin, rmax)
{
   x - runif(1)
   x - x * (rmax - rmin) + rmin
   x
}


Sarah

On Thu, Aug 6, 2009 at 11:02 AM, damien landaisdamien.land...@tdf.fr wrote:
 Hi,
 I would obtain a random value between two (for example between 40.15 and 
 56.58 I would have only one value).
 I'm looking for a package/a function which could do this.
 Could anybody help me please?

 Cordialement
 Damien Landais

-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] random between two values

2009-08-06 Thread Scott Sherrill-Mix
Or just use runif's built-in bounds:
thisMin-40.15
thisMax-56.58
runif(1,thisMin,thisMax)

Scott



Scott Sherrill-Mix
Department of Microbiology
University of Pennsylvania
402B Johnson Pavilion
3610 Hamilton Walk
Philadelphia, PA  19104-6076



On Thu, Aug 6, 2009 at 11:11 AM, Sarah Gosleesarah.gos...@gmail.com wrote:
 That's pretty straightforward to do - here's a simple function. The
 exact behavior
 at the edges is left as an exercise. :)

 rbound - function(rmin, rmax)
 {
   x - runif(1)
   x - x * (rmax - rmin) + rmin
   x
 }


 Sarah

 On Thu, Aug 6, 2009 at 11:02 AM, damien landaisdamien.land...@tdf.fr wrote:
 Hi,
 I would obtain a random value between two (for example between 40.15 and 
 56.58 I would have only one value).
 I'm looking for a package/a function which could do this.
 Could anybody help me please?

 Cordialement
 Damien Landais

 --
 Sarah Goslee
 http://www.functionaldiversity.org

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


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