The code I posted is self contained and, as you can see, works for me. Do the two lines that actually matter
DF <- data.frame(CHR=c("Chr1", "Chr14", "Chr19", "Chr2", "Chr8", "Chr7"))
DF$CHR_N <- as.numeric(sub(pattern = "Chr",replacement = "", DF$CHR))
work for you? If so please post a small example of your data where similar code is not working. If your data frame is named DF, you can post the output of
dput(head(DF))
Please put lines with only three back ticks before and after the output, like this
```
your output here
```