Hi

OK, I now got the point. You have several options

1.            If your data frame is numeric, change it to matrix.
m<-as.matrix(df)
m
      x y
[1,]  1 2
[2,]  1 2
[3,] NA 7
[4,] NA 7
identical(m[1,],m[2,])
[1] TRUE

2.            Or make your own function
nidentical<- function(x,y) {
xn<-as.numeric(x)
yn<-as.numeric(y)
identical(xn,yn)}

nidentical(df[1,],df[2,])
[1] TRUE

which works for matrix too.

Both works also for factor variables  and the second option issues warning when dealing with character values. I did not tested it with other data types.
If you used as.character instead of as.numeric, the result will be probably same (except the warning)

Regards
Petr


From: Jorgen Harmse [mailto:jorgen.harmse@civitaslearning.com]
Sent: Monday, March 11, 2013 2:08 PM
To: PIKAL Petr
Cc: r-help@r-project.org
Subject: Re: [R] Re move row.names column in dataframe

identical(df[1,],df[2,]) is FALSE because of the row names. all( == ) is just a work-around that I attempted.

Jorgen.

On Mar 11, 2013, at 02:53 , PIKAL Petr wrote:



df <- data.frame(x=c(1,1,NA,NA), y=c(2,2,7,7))
identical(df[1,],df[2,])
[1] FALSE
all(df[1,]==df[2,])
[1] TRUE
all(df[3,]==df[4,])
[1] NA

I beg your pardon, whot does row names do with the above result? What do you expect as a result of

all(df[3,]==df[4,])

Regards
Petr


	[[alternative HTML version deleted]]

