[R] easy way to cap a data frame to a max value

From: Grey Moran <grey.moran_at_gmail.com>
Date: Fri, 07 Nov 2008 16:16:52 -0500


Hello,

I have some rather large matrices. Is there a way (without having to loop) to cap all the values of a data frame to a given ceiling? E.g.
junk <- cbind(c(1,2,3,4,5),c(2,4,6,8,10)) > junk

     [,1] [,2]
[1,] 1 2
[2,] 2 4
[3,] 3 6
[4,] 4 8
[5,] 5 10

>" replace anything over the value of 5 with 5..."

Thank you all,

Grey



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. Received on Fri 07 Nov 2008 - 21:19:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 07 Nov 2008 - 22:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive