An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090630/7d940415/attachment-0001.pl>
Indexing matrix
3 messages · Gabor Grothendieck, Rainer M Krug
On Tue, Jun 30, 2009 at 9:19 AM, Rainer M Krug<r.m.krug at gmail.com> wrote:
Hi imagine the following situation: a <- runif(100) plot(a[a>0.5]) plots only the elements in the vector which are larger then 0.5 Now imagine a matrix: b <- matrix(runif(20000), ncol=40, nrow=50) image(b[b>0.5]) Error in image.default(b[b > 0.5]) : argument must be matrix-like Is there a similar way then above to plot an image from the matrix with only the elements larger then 0.5, and the remaining elements equals NA? I know I could do something like image(b, zlim=c(0.5, 1)) but this includes 0.5 in the image, bb <- b bb[bb<=0.5] <- NA image(bb) but this includes an additional assignment.
Although this does involve an assignment underneath as well perhaps its sufficient for your purposes: image(replace(b, b <= 0.5, NA))
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090630/71cf2e98/attachment-0001.pl>