Re: [R-sig-Geo] masking z values (extract or subset on a 3-d array)

2006-05-27 Thread Andy Bunn
>Andy, > >Maybe this is confusing because the data really ought to be in a dataframe >with factors coding for treatments? Can't argue with that logic...it's the principle of the thing you understand. > >Here's one solution: > >foo[,'z',] <- sapply(foo[,'z',], function(x) max(c(x, 0))) > Thanks!

Re: [R-sig-Geo] masking z values (extract or subset on a 3-d array)

2006-05-26 Thread Tim Keitt
Andy, Maybe this is confusing because the data really ought to be in a dataframe with factors coding for treatments? Here's one solution: foo[,'z',] <- sapply(foo[,'z',], function(x) max(c(x, 0))) THK On 5/26/06, Andy Bunn <[EMAIL PROTECTED]> wrote: > > > > This is driving me nuts. I have a 3-

Re: [R-sig-Geo] masking z values (extract or subset on a 3-d array)

2006-05-26 Thread Andy Bunn
> > 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 > >

Re: [R-sig-Geo] masking z values (extract or subset on a 3-d array)

2006-05-26 Thread Roger Bivand
On Fri, 26 May 2006, Andy Bunn wrote: > 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

[R-sig-Geo] masking z values (extract or subset on a 3-d array)

2006-05-26 Thread Andy Bunn
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 wit