I have a dataframe called "missingdata" and some of its rownames are duplicate such as "Austria", "Austria.1" and "Austria.2".
I want to delete those rows entirely, which have a dot in its name.
I have a dataframe called "missingdata" and some of its rownames are duplicate such as "Austria", "Austria.1" and "Austria.2".
I want to delete those rows entirely, which have a dot in its name.
We can use grep
and invert = TRUE
missingdata[grep("Austria\\.\\d+$", row.names(missingdata), invert = TRUE),]
Or if it is not specific to a particular prefix
missingdata[grep("\\.\\d$$", row.names(missingdata), invert = TRUE),]