有没有办法在R中从这个 Dataframe 中提取数字?从字符串中提取整数

kadbb459  于 2023-04-27  发布在  其他
关注(0)|答案(1)|浏览(152)

所以我有下面的 Dataframe

我尝试使用gsub来提取数据,但它不工作,因为它似乎gsub只提取数字而不是整数。有没有任何软件包或函数,将允许我提取整数?
我尽力了

gsub(".*?([0-9]+).*", "\1",Not_Detect_134$Not_Detect_134)

但它只返回

[1] "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001"
  [11] "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001"
  [21] "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001"
  [31] "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001"
  [41] "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001" "\001"
2w2cym1i

2w2cym1i1#

你可以使用这个:str_extract(Not_Detect_134,“\d+”)

相关问题