Re: [R] how to fetch rows with certain characteristics

2009-10-29 Thread Marek Janad
Try > x <- read.table(textConnection( + "1.2 1 + 1.2 1 + 1.3 1 + 1.5 1 + 1.1 2 + 1.2 2 + 9.9 2 + 0.1 3 + 1.1 3 + 1.9 3") ) > x.min <- tapply(x[,1], x[,2], min) > x[x.min[x[,2]]==x[,1],] V1 V2 [1,] 1.2 1 [2,] 1.2 1 [3,] 1.1 2 [4,] 0.1 3 2009/10/29 Ista Zahn > I still don't under

Re: [R] how to fetch rows with certain characteristics

2009-10-29 Thread Ista Zahn
I still don't understand. Please look at the example I provided in my last response. What is it that you want that my example does not do? On Thu, Oct 29, 2009 at 3:08 PM, Waverley @ Palo Alto wrote: > The reason %in% does not work is that there are might be values which > are not min in other cl

Re: [R] how to fetch rows with certain characteristics

2009-10-29 Thread Waverley @ Palo Alto
The reason %in% does not work is that there are might be values which are not min in other class which are the same as the min of different classes. In the example I provided before, this situation did not exist. See the new example: > + 1.2 1 > + 1.3 1 > + 1.5 1 > + 1.1 2 > + 1.2 2 > + 9.9 2 >

Re: [R] how to fetch rows with certain characteristics

2009-10-29 Thread Ista Zahn
Hi, I guess I don't understand why you think %in% won't work. > x <- read.table(textConnection("1.2 1 + 1.2 1 + 1.3 1 + 1.5 1 + 2.1 2 + 2.0 2 + 9.9 2 + 1.4 3 + 1.8 3 + 1.9 3") ) > x <- as.matrix(x) > x.min <- tapply(x[,1], x[,2], min) > x[x[,1] %in% x.min,] > ## all matches V1 V2 [1,] 1.2 1

Re: [R] how to fetch rows with certain characteristics

2009-10-29 Thread Waverley @ Palo Alto
Thanks. That works. However, in my own case, there are more columns of other kinds of data. So to me, it is more important to get the row index of those that has the min values of particular column in particular class (which is another column). Can you help more as how to get those row index? O

Re: [R] how to fetch rows with certain characteristics

2009-10-28 Thread Viechtbauer Wolfgang (STAT)
...@gmail.com] Sent: Thursday, October 29, 2009 6:47 AM To: r-help Subject: [R] how to fetch rows with certain characteristics Hi, I have a matrix, first column is of certain values, second column is the class labels or a factor. e.g. 1.2 1 1.3 1 1.3 1 1.5 1 2.1 2 2.0 2 9.9 2 1.4 3 1.8 3 1.9 3 I want to

[R] how to fetch rows with certain characteristics

2009-10-28 Thread Waverley @ Palo Alto
Hi, I have a matrix, first column is of certain values, second column is the class labels or a factor. e.g. 1.2 1 1.3 1 1.3 1 1.5 1 2.1 2 2.0 2 9.9 2 1.4 3 1.8 3 1.9 3 I want to find out what is the min values of column 1 for each corresponding class (column 2). For the above example, I want to