[R] How to quick check two rows are the same?

Patrick Burns pburns at pburns.seanet.com
Thu Jul 8 10:47:33 CEST 2010


Or possibly use 'all.equal' rather than
'identical' if the data are floating
point numbers.

Also these are columns, not rows.

On 08/07/2010 00:35, Erik Iverson wrote:
> Yi wrote:
>> Hi, folks,
>>
>> Suppose the data is as follows:
>>
>> #######
>>
>> x=1:10
>> y=2:11
>> z=3:12
>>
>> data1=data.frame(x,y)
>> data2=data.frame(x,z)
>>
>> ######
>>
>> In real case, how to check data1$x and data2$x are the same or not? I am
>> using for-loop to do this.
>>
>> Is there a quicker way?
>
> all(data1$x == data2$x)
>
> or
>
> identical(data1$x, data2$x)
>
> ______________________________________________
> R-help at r-project.org 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.
>

-- 
Patrick Burns
pburns at pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')



More information about the R-help mailing list