Hi,
You can use all.equal, like this:
all.equal(c(1,1), mtrx[1,], check.attributes=FALSE)
If you want to check each row of the matrix (I wasn't clear if you
wanted this) you can do something like
check.equal <- function(x, y)
{
isTRUE(all.equal(y, x, check.attributes=FALSE))
}
apply(mtrx, 1
From: xxgr...@hotmail.com
To: r-help-boun...@r-project.org
Subject: compare a vector and a row of a matrix
Date: Sun, 26 Sep 2010 23:23:52 +0800
Hi Everyone:
I am trying to compare a vector and rows of a matrix
for example
> xn <- c(1,2,4,4,5,5,5,6)
>yn <- c(1,2,5,7,1,2,3,1)
2 matches
Mail list logo