I have the following vector in R:
myvec <- c("1.80 m (5 ft 11 in)[2]", "1.81 m (5 ft 11 1⁄2 in)[2]", "1.86 m (6 ft 1 in)[2]", "1.75 m (5 ft 9 in)[2][3][4]")
I want to remove anything that starts with "[", inclusive, so that I end up with:
myvec_clean <- c("1.80 m (5 ft 11 in)", "1.81 m (5 ft 11 1⁄2 in)", "1.86 m (6 ft 1 in)", "1.75 m (5 ft 9 in)")
I've tried the following but it's only removing the first case:
gsub("\\[[\\d-]\\]+", "", myvec)