Thanks Robert

the problem (on your example) this I need

ID <- rep(1:10, each=10)
K <- runif(100)
areaFe <- as.data.frame(cbind(ID, K))
#find the max value in each ID area
> fer.conc.max <- tapply(areaFe$K, areaFe$ID, max, na.rm=TRUE)
> fer.conc.max
        1         2         3         4         5         6
7         8
0.9339687 0.9413441 0.9605550 0.9968569 0.9647085 0.9563837 0.9731356
0.9278238
        9        10
0.9496833 0.9111127
#count the value below or equal the fe.comc.max
> tapply(areaFe$K <= fer.conc.max, areaFe$ID, sum, na.rm=TRUE)
Error tapply(areaFe$K <= fer.conc.max, areaFe$ID, sum, na.rm = TRUE) :
  dims [product 10] do not match the length of object [100]



2009/3/13 Robert Hijmans <[email protected]>

> Dear Gianni,
>
> I think you want this:
>
> tapply(areaFe$K <= fer.conc.max, areaFe$ID, sum, na.rm=TRUE)
>
> E.g.:
>
> ID <- rep(1:10, each=10)
> K <- runif(100)
> areaFe <- as.data.frame(cbind(ID, K))
> fer.conc.max <- 0.5
> tapply(areaFe$K <= fer.conc.max, areaFe$ID, sum, na.rm=TRUE)
>
>
> Robert
>
>
> On Fri, Mar 13, 2009 at 9:58 AM, gianni lavaredo
> <[email protected]> wrote:
> > dear User
> >
> > I'm quite new to R and trying to learn the basic and sorry for the email.
> I
> > don't wish abuse of mail-list. I had read manual and Help online about
> > tapply (...). I have a data frame and I need "count" the Fe value with
> sum
> > for every ID sample area
> >
> > fer.conc.max <- tapply(areaFe$K, areaFe$ID, max, na.rm=TRUE)
> >
> > I need to count the Fe area with Fe$K <=  fer.conc.max
> >
> > # give me the summatory and not the count
> > fer.conc.max <- tapply(areaFe$K, areaFe$ID, sum, na.rm=TRUE)
> >
> > I tried sever combination that I found in mail-list archive but alway I
> have
> > a error message
> >
> > thanks Gianni
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > [email protected]
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to