For instance, I am removing outliers greater than 3SD but there are NAs in my dataset. I would like to calculate the SD, remove those outliers ignoring those with NAs in the calculation, but retaining those with NAs in the final output. It seems using na.rm function would remove NAs in the final data frame produced, so I'm wondering if there's another way to go about this?
Current code I have is:
df_final = df %>%
filter(height < mean(height, na.rm = T) + (3*sd(df$height, na.rm=T)))
Thank you!