how can I extract numbers from a string in R?
问题 names(score) [1] "(Intercept)" "aado2_calc(20,180]" "aado2_calc(360,460]" [4] "aado2_calc(460,629]" "albumin[1,1.8]" "albumin(1.8,2.2]" [7] "albumin(2.2,2.8]" "aniongap(15,18]" "aniongap(18,20]" [10] "aniongap(20,22]" "aniongap(22,25]" "aniongap(25,49]" I want to extract the two numbers within parenthesis (numbers outside the parenthesis are not needed) and there are "(" or "[". the first number will be assigned to an object "low" and the second to "high". 回答1: scorenames <- c( "(Intercept)"