Hi. I have an array with dimensions (720,360,349) where each grid cell has a value. I like to think of it as having 349 'sheets' of 720 by 360 data.

I need to categorize each grid cell into one of 4 categories:

<-2 as apple

-1 to -2 as orange

-1 to 0 as pear

0 to 1 as peach

I would like to use an if else loop to get each grid cell value to be categorized as apple/orange/pear/peach but would the replace function be more suitable? I'm not sure.

After than, I need to count how many apples/orange/pear/peach are in each grid cell and have one array (720,360) for each fruit (4 arrays in total) telling me the count for each grid cell. Obviously, the total number of apples+oranges+pears+peaches should = 349 for each grid cell.

I've tried the count function but I think I'm screwing up the code:

cpeaches<-array(data=NA,dim=c(720,360))

cpeaches=count(extreme[,,1:349],vars="peaches")

Would anyone be kind enough to point me in the right direction?

Thank you!