I have a big df with colnames like this:
dput(head(colnames(count)[c(2,3,4,7,8)]))
c("A001", "A002", "A004", "A008", "A009")
I want to substract the number part and keep the letter, which is not a constant string and in other columns it will be B, C etc. result should look like this:
c("A000", "A001", "A003", "A007", "A008")
So far I was trying this which deals with the number -1 but it doesn't keep the letter.
as.numeric(str_extract(colnames(count), "[0-9]+"))-1
c("0", "1", "3", "7", "8")