or using the %in% operator...
?"%in%"
data[data$label %in% flist,]
regards,
Sean
Applejus wrote:
>
> Hi,
>
> You are right the == doesn't work, but there's a workaround using regular
> expressions:
>
> flist<-"fun|food"
> grep(flist, data$label)
>
> will give you the vector [2 4] which ar
I'm sorry about that. Second line should be
attach(yourdata)
Cheers,
Jorge
On Wed, Apr 23, 2008 at 7:48 PM, Jorge Ivan Velez <[EMAIL PROTECTED]>
wrote:
>
> Try this,
>
> x="label freq1 freq2
> news 54 35
> fun 37 21
> milk19 7
> food 3 3"
>
> yourdata
unter
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Jorge Ivan Velez
Sent: Wednesday, April 23, 2008 4:48 PM
To: Dirkheld
Cc: r-help@r-project.org
Subject: Re: [R] select rows from data based on a vector of char strings
Try this,
x="label fre
Try this,
x="label freq1 freq2
news 54 35
fun 37 21
milk19 7
food 3 3"
yourdata=read.table(textConnection(x),header=TRUE)
attached(yourdata)
flist<-c("fun","food")
yourdata[label %in% flist,]
I hope this helps,
Jorge
On Wed, Apr 23, 2008 at 3:13 AM,
Hi,
You are right the == doesn't work, but there's a workaround using regular
expressions:
flist<-"fun|food"
grep(flist, data$label)
will give you the vector [2 4] which are the numbers of the rows of
interest!
Dirkheld wrote:
>
> Hi,
>
> I have loaded a dataset in R :
> data =
>
> label
On 4/23/2008 3:13 AM, Dirkheld wrote:
> Hi,
>
> I have loaded a dataset in R :
> data =
>
> label freq1 freq2
> news 54 35
> fun 37 21
> milk19 7
> food 3 3
> etc
>
> And I have a vector
> flist<-c("fun","food")
>
> Now I want to use the vector 'fli
Hi,
I have loaded a dataset in R :
data =
label freq1 freq2
news 54 35
fun 37 21
milk19 7
food 3 3
etc
And I have a vector
flist<-c("fun","food")
Now I want to use the vector 'flist' for selecting these values from 'data'
so that I get the followin
7 matches
Mail list logo