2013/7/30 Dimitri Liakhovitski :
> How can I grab only those rows that don't contain any -1s (no matter in
> what columns? Without writing a loop.
> In other words, I want my output to contain only rows 3 and 5 of x.
index <- apply(x, 1, function (x) { !(c(-1) %in% x)})
x[index, ]
a b c d e
3 2
x[!apply(x, 1, function (y) any(y==-1)),]
-- Original Message --
From: "Dimitri Liakhovitski"
To: "r-help"
Sent: 7/30/2013 10:06:02 AM
Subject: [R] Select only rows that don't contain one number
Hello!
I have a data frame:
x<-data.frame(a=c(-1,1,2,3,4),b
Sums(!x==-1)==ncol(x),]
> # a b c d e
> #3 2 3 3 4 3
> #5 4 5 5 6 4
>
>
> A.K.
>
>
>
>
> - Original Message -
> From: Dimitri Liakhovitski
> To: r-help
> Cc:
> Sent: Tuesday, July 30, 2013 10:06 AM
> Subject: [R] Select only rows that do
itski
To: r-help
Cc:
Sent: Tuesday, July 30, 2013 10:06 AM
Subject: [R] Select only rows that don't contain one number
Hello!
I have a data frame:
x<-data.frame(a=c(-1,1,2,3,4),b=c(1,-1,3,4,5),c=1:5,d=2:6,e=c(1,2,3,-1,4))
x
How can I grab only those rows that don't contain any -1s
Subject: [R] Select only rows that don't contain one number
Hello!
I have a data frame:
x<-data.frame(a=c(-1,1,2,3,4),b=c(1,-1,3,4,5),c=1:5,d=2:6,e=c(1,2,3,-1,4))
x
How can I grab only those rows that don't contain any -1s (no matter in
what columns? Without writing a loop.
In other
Thanks a a lot, Jose!
On Tue, Jul 30, 2013 at 10:19 AM, José María Mateos wrote:
> 2013/7/30 Dimitri Liakhovitski :
> > How can I grab only those rows that don't contain any -1s (no matter in
> > what columns? Without writing a loop.
> > In other words, I want my output to contain only rows 3 an
Hello!
I have a data frame:
x<-data.frame(a=c(-1,1,2,3,4),b=c(1,-1,3,4,5),c=1:5,d=2:6,e=c(1,2,3,-1,4))
x
How can I grab only those rows that don't contain any -1s (no matter in
what columns? Without writing a loop.
In other words, I want my output to contain only rows 3 and 5 of x.
Thank you ve
7 matches
Mail list logo