假设特征特性列名为Feature,可以使用以下代码:

library(tidyverse)

df <- df %>% 
  mutate(Feature = str_extract_all(Feature, "\\d+")) %>% 
  unnest(Feature) %>% 
  mutate(Feature = as.numeric(Feature)) %>% 
  filter(Feature > 1000) %>% 
  pull(Feature) %>% 
  paste(collapse = ",")

首先使用str_extract_all函数从Feature列中提取所有数字,然后使用unnest函数将数字拆分成行。接着使用as.numeric函数将提取出的数字转换为数字类型,然后使用filter函数筛选出大于1000的数字。最后使用pull函数提取出Feature列中所有符合条件的数字,然后使用paste函数将它们以逗号隔开。结果将保存在df变量中。

excel含有含有特征特性列为文本类型现利用tidyverse提取特征特性中大于1000的全部数字并以逗号隔开

原文地址: https://www.cveoy.top/t/topic/d66U 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录