If I have a DataFrame
object, but I want to use a classification algorithm like randomForest
from CRAN, which complains about S4 objects being input, what is the best way to coerce to a data.frame
? I would like to keep column names in the current gene symbol format. They might have unusual symbols like HLA-A, for example. as.data.frame
automatically converts column names to by syntactically valid, by doing things such as replancing hyphens by periods. data.frame(myDataFrame, check.names = FALSE)
effectively does what I want. But, it's a constructor rather than a function to convert between types. Anything better to use?
Oh. You were using
as.data.frame
. That just ends up re-creating thedata.frame
, and on top of it all there's an...
argument that is ignored! LOLHoweva, there is the 'optional' argument that you could use, and which is documented, so hypothetically you could have just figured this out yourself.
From
?as.data.frame
, and then following to?base::as.data.frame
you will see