Does this do it for you?
sum((df$x >= xleft) & (df$x <= xright) & (df$y >= ybottom)
& (df$y <= ytop))
On 5/11/07, Jason Vytlacil <jason.vytlacil at gmail.com>
wrote:> I'm a newbie, so please forgive me:
>
> I have a data frame that includes two long columns of x and y coordinate
> values thusly:
> ... ... ... x y ... ...
> ... ... ... 115 127 ... ...
> ... ... ... 120 129 ... ...
> ... ... ... 0 0 ... ...
> ... ... ... 135 162 .... ...
> ect...
>
> i need to ask R tell me how many x-y pairs contain coords that are
> non-zero and fall within values that i'm callilng xleft, xright,
ybottom and
> ytop and fall between certain indicies of the data frame.
> i am calling the indexes by referring to numbers i have storied in other
> variables. i am really looking for an efficient way to do this since when
i
> try to pull the x and y columns out and assign them to their own variables,
> the process of asking for the number of non-zeros which have x values such
> that xleft <= x <= xright AND ybottom <= y <=ytop, the process
becomes very
> convoluted. how can i ask for more than one conditional at once?
> thanks for any help,
> jason
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?