From: <Davaren1_at_aol.com>

Date: Sat 31 Jul 2004 - 02:32:14 EST

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 31 03:18:33 2004

Date: Sat 31 Jul 2004 - 02:32:14 EST

Dear R-help,

I have a question on subsetting a dataframe and I searched all of R-help to no avail. Please view the following example dataframe:

# Example

*> x <- factor(rep(c(1,2,3,4),2))
**> y <- c(1,4,3,2,1,2,5,1,2)
**> z <- c(10,12,18,21,24,32,34,12,23)
*

> test <- data.frame(x, y, z)

*> test
*

x y z

1 1 1 10

2 2 4 12

3 3 3 18

4 4 2 21

5 1 1 24

6 2 2 32

7 3 5 34

8 4 1 12

I want to subset "y" that is >=4 and return all matching "x" that were found from y>=4. I know I can do the following:

> test.new <-subset(test, y>=4)

> test.new

x y z

2 2 4 12

7 3 5 34

I am trying for the following output:

> test.new

x y z

2 2 4 12

3 3 3 18

6 2 2 32

7 3 5 34

I appreciate any help.

Very respectfully,

D. Arenas

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 31 03:18:33 2004

*
This archive was generated by hypermail 2.1.8
: Fri 18 Mar 2005 - 02:41:27 EST
*