[R] Rounding Elements of a Matrix
David Winsemius
dwinsemius at comcast.net
Mon Sep 20 18:44:52 CEST 2010
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
More information about the R-help
mailing list