Skip to content
Prev 228668 / 398500 Next

Convert Row Names to data.frame column

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:
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?