I have the following character vector than I need to modify with gsub
.
strings <- c("x", "pm2.5.median", "rmin.10000m", "rmin.2500m", "rmax.5000m")
Desired output of filtered strings
:
"x", "pm2.5.median", "rmin", "rmin", "rmax"
My current attempt works for everything except the pm2.5.median
string which has dots that need to be preserved. I'm really just trying to remove the buffer size that is appended to the end of each variable, e.g. 1000m
, 2500m
, 5000m
, 7500m
, and 10000m
.
gsub("\\..*m$", "", strings)
"x", "pm2", "rmin", "rmin", "rmax"