You could use gsub
here
x<-c("s1-112", "s10-112", "s3656-112")
gsub("s(.*)-112", "\\1", x)
# [1] "1" "10" "3656"
1
solved Changing a column of a dataframe in R
You could use gsub
here
x<-c("s1-112", "s10-112", "s3656-112")
gsub("s(.*)-112", "\\1", x)
# [1] "1" "10" "3656"
1
solved Changing a column of a dataframe in R