logo       

masking z values (extract or subset on a 3-d array): msg#00060

lang.r.geo

Subject: masking z values (extract or subset on a 3-d array)

This is driving me nuts. I have a 3-D array that holds x,y,z coordinates
from multiple experiments. I need to clean the data before making it sp
objects. I want to set all z-values < 0 to 0. In a 2-D matrix this is
trivial e.g., x[,x[1,]<0] <- 0. But I'm stumped on how to do this on a 3-D
array without a loop. Given an array:

foo <- array(rnorm(24), dim=c(4,3,2))
dimnames(foo) <- list(NULL,c('x','y','z'),c('Experiment1','Experiment2'))
foo[,'z',]

How can I set foo[,'z',]<0 to 0?


Thanks, Andy


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise