I have a 2x50 matrix and would like to round all the elements to 2 decimal places. Can any one help? Thanks, Raphael
Hi Raphael, mat <- matrix(rnorm(100), ncol = 2) round(mat, 2) for documentation see ?round Cheers, Josh On Mon, Sep 20, 2010 at 9:21 AM, Raphael Fraser <raphael.fraser at gmail.com> wrote:> I have a 2x50 matrix and would like to round all the elements to 2 > decimal places. Can any one help? > > Thanks, > Raphael > > ______________________________________________ > R-help at 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. >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
On Sep 20, 2010, at 12:25 PM, Joshua Wiley wrote:> Hi Raphael, > > mat <- matrix(rnorm(100), ncol = 2) > round(mat, 2) > > for documentation see ?round >Thanks, Josh. I was having trouble a couple of minutes ago remembering this. Getting old, I guess. In constructing my thanks to Josh I tested: print(mat, digits=2) ... and also got what I had been aiming for with my results. The print strategy has the advantage that the underlying data is not mucked with. -- David.> Cheers, > > Josh > > On Mon, Sep 20, 2010 at 9:21 AM, Raphael Fraser > <raphael.fraser at gmail.com> wrote: >> I have a 2x50 matrix and would like to round all the elements to 2 >> decimal places. Can any one help? >> >> Thanks, >> Raphael >> >> ______________________________________________ >> R-help at 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. >> > > > > -- > Joshua Wiley > Ph.D. Student, Health Psychology > University of California, Los Angeles > http://www.joshuawiley.com/ > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT
Thank you all On Mon, Sep 20, 2010 at 12:53 PM, Zoppoli, Gabriele (NIH/NCI) [G] <zoppolig at mail.nih.gov> wrote:> see help(round) > > Gabriele Zoppoli, MD > Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of Genova, Genova, Italy > Guest Researcher, LMP, NCI, NIH, Bethesda MD > > Work: 301-451-8575 > Mobile: 301-204-5642 > Email: zoppolig at mail.nih.gov > ________________________________________ > From: Raphael Fraser [raphael.fraser at gmail.com] > Sent: Monday, September 20, 2010 12:21 PM > To: r-help at r-project.org > Subject: [R] Rounding Elements of a Matrix > > I have a 2x50 matrix and would like to round all the elements to 2 > decimal places. Can any one help? > > Thanks, > Raphael > > ______________________________________________ > R-help at 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. >