Yes, there is no such luxury in the default histogram command.
If we really want to get rid of the outliers in histograms,
we need to either find out a special package which would give you an option for the outliers
or remove the outliers in our data first and then plot it using the default histogram.
Since I cannot recall a specific package, let me introduce a function which removes the outliers in your data:
remove_outliers <- function(x, na.rm = TRUE, ...) {
qnt <- quantile(x, probs=c(.25, .75), na.rm = na.rm, ...)
H <- 1.5 * IQR(x, na.rm = na.rm)
y <- x
y[x < (qnt[1] - H)] <- NA
y[x > (qnt[2] + H)] <- NA
y
}If you run this entire code in RStudio and use it by "out<-remove_outlier(YOUR DATA)",
then "hist(out)" will give you the desired histogram with no outliers.
Lastly, the outlier detection rule used in this code is called "1.5*IQR rule".
You can find an explanation here:
https://www.youtube.com/watch?v=FRlTh5HQORA