On Thu, Nov 25, 2010 at 4:59 AM, Luedde, Mirko wrote:
> Dear all,
>
> this looks pretty much a standard problem, but I couldn't find a
> satisfying and understandable solution.
>
> (A) Given a data frame (or matrix), e.g.
>
> x <- data.frame(A=c(1, 2, 2), B=c(4, 5, 5))
>
> and a row of thi
Try this:
which((apply(x, 1, toString) %in% toString(r)))
On Thu, Nov 25, 2010 at 7:59 AM, Luedde, Mirko wrote:
> Dear all,
>
> this looks pretty much a standard problem, but I couldn't find a
> satisfying and understandable solution.
>
> (A) Given a data frame (or matrix), e.g.
>
> x <- d
: Luedde, Mirko
Cc: r-help@r-project.org
Betreff: Re: [R] how to find a row index in a matrix or a data frame ?
rows <- which(apply(mapply(x, r, FUN="=="), MARGIN=1, FUN=all));
/H
On Thu, Nov 25, 2010 at 1:59 AM, Luedde, Mirko wrote:
> Dear all,
>
> this looks pretty much a s
rows <- which(apply(mapply(x, r, FUN="=="), MARGIN=1, FUN=all));
/H
On Thu, Nov 25, 2010 at 1:59 AM, Luedde, Mirko wrote:
> Dear all,
>
> this looks pretty much a standard problem, but I couldn't find a
> satisfying and understandable solution.
>
> (A) Given a data frame (or matrix), e.g.
>
>
Mirko,
Here is a solution - I am sure other R mentors would find a more efficient
one
> x <- data.frame(A=c(1, 2, 2), B=c(4, 5, 5))
> x <- rbind(x,x)
> r <- c(2,5)
>
> (rowfind=apply(x,1,FUN=function(row,add){isTRUE(all.equal(row,add,check.attributes
= FALSE))},add=r))
1 2 3 4 5 6
FALSE TR
Dear all,
this looks pretty much a standard problem, but I couldn't find a
satisfying and understandable solution.
(A) Given a data frame (or matrix), e.g.
x <- data.frame(A=c(1, 2, 2), B=c(4, 5, 5))
and a row of this data frame, e.g.
r <- c(2, 5)
I need to find one row
6 matches
Mail list logo