[R] locate the rows in a dataframe with some criteria

2008-03-07 Thread zhihuali

Hi, netters,

This is probably a rookie question but I couldn't find the answer after hours 
of searching and trying.

Suppose there'a a dataframe M:

x y
10   A
13   B
8 A
 11   A

I want to locate the rows where x =10 and y=A. I know how to do it to 
vectors by using 
which, but how to do it with the dataframe?

Thank you very much!


Zhihua Li

_
MSN ÖÐÎÄÍø£¬×îÐÂʱÉÐÉú»î×ÊѶ£¬°×Áì¾Û¼¯ÃÅ»§¡£

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] locate the rows in a dataframe with some criteria

2008-03-07 Thread Charilaos Skiadas
On Mar 7, 2008, at 10:50 AM, zhihuali wrote:


 Hi, netters,

 This is probably a rookie question but I couldn't find the answer  
 after hours of searching and trying.

 Suppose there'a a dataframe M:

 x y
 10   A
 13   B
 8 A
  11   A

 I want to locate the rows where x =10 and y=A. I know how to do  
 it to vectors by using
 which, but how to do it with the dataframe?


Does ?subset do what you want?

 Thank you very much!


 Zhihua Li


Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

__
R-help@r-project.org 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.


Re: [R] locate the rows in a dataframe with some criteria

2008-03-07 Thread N. Lapidus
Hi Zhihua,

M - data.frame (x=c(10, 13, 8, 11), y=c('A', 'B', 'A', 'A'))
which (M$x = 10  M$y == 'A')
# [1] 1 4

Hope it helps,
Nael

2008/3/7 N. Lapidus [EMAIL PROTECTED]:

 Hi Zhihua,

 M - data.frame (x=c(10, 13, 8, 11), y=c('A', 'B', 'A', 'A'))
 which (M$x = 10  M$y == 'A')
 # [1] 1 4

 Hope it helps,
 Nael


 2008/3/7 zhihuali [EMAIL PROTECTED]:

 
  Hi, netters,
 
  This is probably a rookie question but I couldn't find the answer after
  hours of searching and trying.
 
  Suppose there'a a dataframe M:
 
  x y
  10   A
  13   B
  8 A
   11   A
 
  I want to locate the rows where x =10 and y=A. I know how to do it to
  vectors by using
  which, but how to do it with the dataframe?
 
  Thank you very much!
 
 
  Zhihua Li
 
  _
  MSN ÖÐÎÄÍø£¬×îÐÂʱÉÐÉú»î×ÊѶ£¬°×Áì¾Û¼¯ÃÅ»§¡£
 
 [[alternative HTML version deleted]]
 
 
  __
  R-help@r-project.org 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.
 
 


[[alternative HTML version deleted]]

__
R-help@r-project.org 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.