I want to have the following code from data.table
in a dplyr way:
library(tidyverse)
library(data.table)
Iris <- as.data.table(iris)
Iris[, .(m = mean(Sepal.Width[Sepal.Width < 3])), Species]
This is what I have so far:
Iris %>%
group_by(Species) %>%
summarise(m = mean(Sepal.Width))
But I do not know where I can place my condition Sepal.Width < 3
.