[R-sig-Geo] help to select a data.frame in fuction of ID

Robert J. Hijmans r.hijmans at gmail.com
Fri Oct 22 06:07:23 CEST 2010


Gianni,

Is this what you are looking for?

mydata$limit2 <- mydata$limit * 2
mydata[mydata$H > mydata$limit2, ]

Robert

On Thu, Oct 21, 2010 at 9:06 AM, gianni lavaredo
<gianni.lavaredo at gmail.com> wrote:
> Dear Researchers,
>
> sorry If I ask a simple question, but this night I have no idea to resolv
> this question. I have a data.frame (just a simple example)
>
>
> mydata <- data.frame(id=c(1,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,5),
> H=c(1,30,43,67,33,78,90,45,4,8,34,3,82,94,12,15,62,89,3,56,96,3),
> limit=c(4,4,4,4,4,3,3,3,3,6,6,6,6,7,7,7,7,8,8,8,8,8))
>
>
> i wish to select by "id" the row with "H" value >= of the boulde of limit (H
>>= limit*2) to have a new data.frame
>
> mydata
>   id  H limit limit2
> 2   1 30     4      8
> 3   1 43     4      8
> 4   1 67     4      8
> 5   1 33     4      8
> 6   2 78     3      6
> 7   2 90     3      6
> 8   2 45     3      6
> 11  3 34     6     12
> 13  3 82     6     12
> 14  4 94     7     14
> 16  4 15     7     14
> 17  4 62     7     14
> 18  5 89     8     16
> 20  5 56     8     16
> 21  5 96     8     16
>
>
> thanks and sorry for desturb with easy question
>
> gianni
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list