I am trying to create a histogram using Sturges' bining rule, yet I keep getting 2 errors, which probably have to do with the variable I am using, maybe because it has NA's?
Here is my process and the errors, what would you suggest?
k <- ggplot (world, aes (x=polstab))
wid <- ceiling ((max(world$polstab)- min (world$polstab))/ nclass.Sturges(world$polstab))
k + geom_histogram(col = "black", fill = "white", binwidth = wid)
Now, I get two error messages:
Removed 9 rows containing non-finite values (stat_bin).
and:
Computation failed in
stat_bin()
: missing value where TRUE/FALSE needed
The first one I understand, the second one is more problematic. What could I do to remove this error?