[R] Convert Row Names to data.frame column
chipmaney
chipmaney at hotmail.com
Sat Jul 24 00:18:21 CEST 2010
Here is an example dataset:
ZoneCover.df<- data.frame(Value=c(1,2))
row.names(ZoneCover.df) <- c("Floodplain1.Tree", "Floodplain1.Shrub")
I want to Export the Row.Names to a column in the dataframe:
ZoneCover.df$ID <- names(ZoneCover.df)
which yields this:
> ZoneCover.df
Value ID
Floodplain1.Tree 1 Floodplain1.Tree
Floodplain1.Shrub 2 Floodplain1.Shrub
QUESTION:
How do I remove the .Tree and .Shrub extensions from the ZoneCover$ID
values?
--
View this message in context: http://r.789695.n4.nabble.com/Convert-Row-Names-to-data-frame-column-tp2300758p2300758.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list