print(rnorm(1),digits=3) The key is understanding the difference between the value and what is printed automatically with the default number of digits given by the options() value currently in effect.
?options for "digits" -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of John Kane > Sent: Friday, April 21, 2006 3:59 PM > To: zhongmiao wang; [email protected] > Subject: Re: [R] how to control the data type > > Have a look at ?round for one way. > > ----- Original Message ---- > From: zhongmiao wang <[EMAIL PROTECTED]> > To: [email protected] > Sent: Thursday, April 20, 2006 11:00:25 PM > Subject: [R] how to control the data type > > Hello: > I am generating a random number with rnorm(1). The generated number > has 8 decimals. I don't want so many decimals. How to control the > number of decimals in R? > Thanks! > > Zhongmiao Wang > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
