[R] re stricting points in a data frame
dxc13
dxc13 at health.state.ny.us
Wed Jan 30 17:19:55 CET 2008
useR's,
Consider some variables and a data frame of points:
x1 <- c(1,2,3)
x2 <- c(3,4,5)
xk1 <- seq(min(x1)-.5, max(x1)+.5,.5)
xk2 <- seq(min(x2)-.5, max(x2)+.5,.5)
expand.grid(xk1=xk1,xk2=xk2)
xk1 xk2
1 0.5 2.5
2 1.0 2.5
3 1.5 2.5
4 2.0 2.5
5 2.5 2.5
6 3.0 2.5
7 3.5 2.5
...
46 2.0 5.5
47 2.5 5.5
48 3.0 5.5
49 3.5 5.5
I want to restrict the data frame to only contain points that are within the
x1 and x2 range. So for this example, only points between 1 and 3 should be
kept for x1 and values between 3 and 5 should be kept for x2. This
condition needs to be satisfied for both points, not just one of them; i.e.,
if an x1 point satisfies this, but its corresponding x2 point does not, then
this point should be removed.
Does anyone know a way to do this, in general, for any data frame?
Hope this is not confusing.
Thanks in advance
dxc13
--
View this message in context: http://www.nabble.com/restricting-points-in-a-data-frame-tp15184381p15184381.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list