【发布时间】:2019-05-18 00:57:43
【问题描述】:
我试图仅在“=”字符串之后提取数字
strings <- c("1t clever=120","3c stupid=-150 bad","5k high iq=150 good")
尝试过
as.numeric(gsub("[^\\d]+","",strings,perl = TRUE))
这给了
[1] 1120 3150 5150
预期输出
120 -150 150
我怎样才能得到这个输出?
【问题讨论】:
-
您的预期输出不仅有非负数。