Hi all,
I just stumbled across the difference between explicit and 'automatic' row
names for data frames. Is there a quick way to find out if a data frame has
automatic row names or not? Of course I know this for data frames that I
create myself, but what if a function needs to extract this information for
an argument?
The following example shows that this property is not easily visible:
# data frame with automatic row names
df <- data.frame(a=1:2, b=3:4)
# data frame with explicit row names
df2 <- data.frame(a=1:2, b=3:4, row.names=1:2)
# printing does not reveal any difference
df
# both are considered equal
all.equal(df, df2)
# calling rownames gives the same result
rownames(df)
# when converting to a matrix, it makes a difference
as.matrix(df)
?a b
1 1 3
2 2 4
Thanks for any suggestion,
Andreas
--
Andreas Borg
Medizinische Informatik