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

From: N. Lapidus <n.lapidus_at_gmail.com>
Date: Fri, 07 Mar 2008 17:02:57 +0100

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 <n.lapidus_at_gmail.com>:

> 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 <lzhtom_at_hotmail.com>:
>
> >
> > 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_at_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_at_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. Received on Fri 07 Mar 2008 - 16:10:11 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 Fri 07 Mar 2008 - 16:30:20 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.

list of date sections of archive