On 8/30/06, Mark Lyman <[EMAIL PROTECTED]> wrote:
> > I have a problem with apply function. I have to two matrices of dimension of
> > one column but n rows. I have to check whether one matrix is greater than
> > other by going thru each row (ie) using if condition to check one matrix
> > with another matrix.
> >
> > I like to use apply() function to this approach. That is apply function
> > between two matrices. I searched for examples online but I couldn't find
> > any.
> >
> > I don't know how to loop thru the matrices.
>
> You can use the functions all.equal with the function isTRUE (see ?all.equal) 
> to
> check if two objects are nearly equal (within a certain tolerance). Or you can
> use identical (see ?identical) to check if they are exactly the same. See the
> examples in the help for identical.

A possible solution could be:

> x <- 1:5
> x
[1] 1 2 3 4 5
> y <- 2:6
> y
[1] 2 3 4 5 6
> all((y-x)>0)
[1] TRUE

The result TRUE means that each element of y is greater than the
homologous element in x.

Paul

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to