[R] Selecting the non-attribute part of an object

2012-11-15 Thread Jonathan Dushoff
I have two matrices, generated by R functions that I don't understand. I want to confirm that they're the same, but I know that they have different attributes. If I want to compare the dimnames, I can say identical(attr(tm, dimnames), attr(tmm, dimnames)) [1] FALSE or even:

Re: [R] Selecting the non-attribute part of an object

2012-11-15 Thread Bert Gunter
max(abs(x-y)) numerical tolerance of your choice -- Bert On Thu, Nov 15, 2012 at 11:52 AM, Jonathan Dushoff dush...@mcmaster.ca wrote: I have two matrices, generated by R functions that I don't understand. I want to confirm that they're the same, but I know that they have different

Re: [R] Selecting the non-attribute part of an object

2012-11-15 Thread William Dunlap
Sent: Thursday, November 15, 2012 11:53 AM To: r-help@r-project.org Subject: [R] Selecting the non-attribute part of an object I have two matrices, generated by R functions that I don't understand. I want to confirm that they're the same, but I know that they have different attributes

Re: [R] Selecting the non-attribute part of an object

2012-11-15 Thread Rolf Turner
I think that what you are looking for is: all.equal(tm,tmm,check.attributes=FALSE) But BEWARE: m - matrix(1:36,4,9) mm - matrix(1:36,12,3) all.equal(m,mm,check.attributes=FALSE) gives TRUE!!! I.e. sometimes attributes really are vital characteristics. cheers,

Re: [R] Selecting the non-attribute part of an object

2012-11-15 Thread Jonathan Dushoff
Thanks for all of these useful answers. Thanks also to Ben Bolker, who told me offline that c() is a general way to access the main part of an object (not tested). I also tried: identical(matrix(tm), matrix(tmm)) [1] TRUE which also works, but does _not_ solve the problem Rolf warns about