Re: [R] conditional across frames of a data fram

From: jim holtman <jholtman_at_gmail.com>
Date: Fri, 11 May 2007 21:55:25 -0400

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?

______________________________________________
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.
Received on Sat 12 May 2007 - 01:59:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 May 2007 - 03:31:58 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.