I don't have your data, but using the iris dataset, the equivalent approach might look something like :
library(tidyverse)
# make an example dataset with some pesky NA values sprinkled in
spoiliris <- iris
spoiliris[1,1] <- NA
spoiliris[10,2] <- NA
spoiliris[101,3] <- NA
in step by step
# determine what the 80 percentile of sepal.length variable is
(q80 <- quantile(spoiliris$Sepal.Length,probs = 0.8,na.rm=TRUE))
#filter on the value
(spiris_within_q80 <- filter(spoiliris,
Sepal.Length <= q80))
#summarise the result
summarise(spiris_within_q80,
Petal.Width_mean = mean(Petal.Width,na.rm=TRUE))
in a more condensed form
filter(spoiliris,
Sepal.Length <= quantile(Sepal.Length,probs = 0.8,na.rm=TRUE)) %>%
summarise( Petal.Width_mean =
mean(Petal.Width,na.rm=TRUE))