Skip to content

Re move row.names column in dataframe

8 messages · PIKAL Petr, Jorgen Harmse, Peter Ehlers

#
... the row.names will not interfere with any merging operation ...

Row names do not interfere with merge, but they cause other problems. In the
example, I want to test whether rows have the same entries (in some or all
columns). identical fails because of the row names, and all( == ) can fail
if there are NAs. There are ways around this, but it would be cleaner to be
able to remove row names.
[1] FALSE
[1] TRUE
[1] NA




--
View this message in context: http://r.789695.n4.nabble.com/Remove-row-names-column-in-dataframe-tp856647p4660743.html
Sent from the R help mailing list archive at Nabble.com.
2 days later
#
Hi
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
#
It isn't necessarily numeric.
I think that's the solution, but the function has to handle both NA and
non-numeric.

equal.NA <- function(x,y)
all(is.na(x)==is.na(y)) && all(is.na(x) | x==y)

I'm still worried that row names could bite me in some other way, and would
prefer to be able to discard them.




--
View this message in context: http://r.789695.n4.nabble.com/Remove-row-names-column-in-dataframe-tp856647p4660956.html
Sent from the R help mailing list archive at Nabble.com.
#
On 2013-03-11 06:07, Jorgen Harmse wrote:
I would just wrap the elements in c():

  identical( c(df[1,]), c(df[2,]) )

Peter Ehlers
2 days later
#
Hi
As you did not include my answer I can not be 100% sure but for comparison purpose matrix way behaves correctly 

Regards
Petr