基于另一列的最大值有条件地筛选组的元素(dplyr::group_by)
此外,在每个TOF组中,只应保留intFT最高的前三个元素 不应删除NA值 这将返回不正确的解决方案:基于另一列的最大值有条件地筛选组的元素(dplyr::group_by),r,filter,dplyr,conditional-statements,subset,R,Filter,Dplyr,Conditional Statements,Subset,此外,在每个TOF组中,只应保留intFT最高的前三个元素 不应删除NA值 这将返回不正确的解决方案: intFT > max(intFT) * 0.1 ### this condition is valid within-group, i.e. max(intFT) refers to the highest intFT in a certain TOF group grouped by dplyr::group_by 我没有你的数据,但像这样的东西可以工作 df %>% dpl
intFT > max(intFT) * 0.1 ### this condition is valid within-group, i.e. max(intFT) refers to the highest intFT in a certain TOF group grouped by dplyr::group_by
我没有你的数据,但像这样的东西可以工作
df %>% dplyr::group_by(TOF) %>% filter(intFT > max(intFT) * 0.1)
我无法复制它看看mtcars%>%group\U bycyl%>%filtermpg>maxmpg*.9
df %>% dplyr::group_by(TOF) %>% filter(intFT > max(intFT) * 0.1)
df %>%
dplyr::group_by(TOF) %>%
add_tally %>%
mutate(remove_it = if_else(n > 2 | intFT < max(intFT) * 0.1),"yes","no") %>%
filter(remove_it == "no") %>%
top_n(3)