【发布时间】:2021-02-27 23:37:48
【问题描述】:
我有一个问题我一直在摸索一分钟。我有一个数据框,其中有一列字符的格式为 1146-01、1148-02、1132-11 等。前四位数字是朱利安数,后两位代表样本数。我想根据月份进行过滤(即 2 月份是 1132-:1159:)我试过这个:
dates <- c(1132:1159)
dates <- as.character(dates)
new <- data %>%
filter(str_detect(Sample.Number, dates)) %>%
以及使用 %in% 运算符,但没有这样的运气。
感谢您的帮助!
【问题讨论】:
-
如果您创建一个小的可重现示例以及预期的输出,这将更容易提供帮助。阅读how to give a reproducible example。