On Tue, Jun 30, 2009 at 3:26 PM, Gabor Grothendieck <ggrothendi...@gmail.com > wrote:
> On Tue, Jun 30, 2009 at 9:19 AM, Rainer M Krug<r.m.k...@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)) > Yes - thanks. I always forget about replace(). The result would work, but the principle is different to the indexing for vectors. But as I am expecting something different then in vector indexing (same dimension), I think the replace() is the best way to go. -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[alternative HTML version deleted]] ______________________________________________ R-help@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.