【发布时间】:2021-02-11 21:53:58
【问题描述】:
我正在尝试识别具有重复数字序列的数据框中的列值。 比如
> df
ColA
1 66046
2 73947
3 67456
4 67217
5 66861
6 67658
我想返回 66046, 66861 因为 6 连续出现。 我已经尝试了以下...
df %>% filter(str_detect(as.String(df[1]), "[66]")) #with and without the squared brackets.
df[unlist(gregexpr("[6]{2}[[:digit:]]", df[1])), ][1]
很明显,这是行不通的。任何帮助表示赞赏。
谢谢
【问题讨论】: