[R] compare a vector and a row of a matrix

2010-09-26 Thread xinxin xx
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)

Re: [R] compare a vector and a row of a matrix

2010-09-26 Thread Ista Zahn
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,