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

Erik Iverson eriki at ccbr.umn.edu
Thu Jul 8 01:35:09 CEST 2010


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)



More information about the R-help mailing list