Hi cruddy,
Maybe I am wrong on this, but it seems to me that freq=F is not working because you also use plot=FALSE . Below is a reprex in base-R yielding the histograms and densities on top of each other. I broke down the structure of hist_x which shows the density part. Here it does not sum to 1, only by multiplying by diff(breaks). The multiplication is exactly what freq=Fdoes, if I understand correctly. In your code, the assignment throughs the warning freq=F not used.
Hope this helps?
JW
x <- rnorm(500)
hist_x<- hist(x, breaks=50, plot = FALSE)
str(hist_x)
#> List of 6
#> $ breaks : num [1:60] -2.6 -2.5 -2.4 -2.3 -2.2 -2.1 -2 -1.9 -1.8 -1.7 ...
#> $ counts : int [1:59] 1 2 0 2 1 4 1 8 6 7 ...
#> $ density : num [1:59] 0.02 0.04 0 0.04 0.02 ...
#> $ mids : num [1:59] -2.55 -2.45 -2.35 -2.25 -2.15 -2.05 -1.95 -1.85 -1.75 -1.65 ...
#> $ xname : chr "x"
#> $ equidist: logi TRUE
#> - attr(*, "class")= chr "histogram"
sum(hist_x$density)
#> [1] 10
sum(diff(hist_x$breaks)*hist_x$density)
#> [1] 1
hist(x,
breaks=50,
freq=FALSE,
xlab = "x",
main = "Histogram and density plot",
col="lightgreen",
xlim=c(-5,5),
ylim=c(0,0.50))
curve(dnorm(x), add=TRUE, col="darkblue", lwd=2)
[image]
Created on 2021-03-07 by the reprex package (v0.3.0)