x <- rnorm( 20000, 5, 2.5 )

The requirement for "random" is ill-specified because it omits mention of which 
random distribution you want (I assumed normal distribution above).

The requirement for "decimal places" is ill-defined because floating point 
numbers are internally represented with mantissa and exponent ("scientific 
notation"), so large numbers have fewer significant "decimal places" in the 
fraction than small numbers do. For most purposes double precision IEEE754 
numbers have more precision than you will need. What gets sticky is if you want 
to LIMIT the number of decimals... you may need to use the sprintf function and 
export the data as character values if that is important (which I doubt).

Note that the default behavior of the R console is to PRINT values with four 
decimals, but the rest of the significant digits are really still there. 
-- 
Sent from my phone. Please excuse my brevity.

On August 2, 2016 11:56:35 AM PDT, Adrian Johnson <oriolebaltim...@gmail.com> 
wrote:
>Dear group,
>
>I am trying to generate a vector of random numbers for 20K observation.
>
>however, I want to generate numbers (with 6 decimal places) within the
>range of
>Std. Dev : 2-3
>mean  : 4-6
>
>Is there a method to generate numbers with 6 decimal places under
>these parameters
>
>thank you.
>Adrian
>
>______________________________________________
>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.

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

Reply via email to