How to calculate skewness of data from histogram in R? In R, the function skewness from package moments allows one to calculate the skewness of the distribution from a given sample. Does anybody know if there is a ready-to-use function to calculate the skewness of the distribution from a given histogram?
 A: Sounds like you're looking at a published histogram and don't have the actual data?
If that is the case you could calculate a rough skewness figure by doing something like pub_his <- c(rep(10,16),rep(15,18),rep(20,27)...), picking the mid point of each bar and reading the frequency off the graph, then you'd have the data and could use the skewness function.
A: In the case of variance (and indeed for the fourth central moment), the "taking the bin center" approach carries a bias.
Such bias can be corrected, via what are known as Sheppard's correction e.g. see here, which in the case of variance would subtract $\frac{1}{12}$ of the square of the bin-width from the binned estimate of the second moment. However, in the case of the third moment, no such adjustment is needed.
On the other hand, the third-moment-skewness, if just calculated directly by dividing the binned third-moment by the unadjusted binned-variance to the power $\frac{3}{2}$ will yield too large a denominator, and so the skewness will be on average slightly underestimated.
This suggests that the binned variance be adjusted by Sheppard's correction before computing the skewness. So:
1) calculate the binned moments (first, second, third) as needed (i.e. by taking every observation at its bin center and if possible using the weighted/grouped-data formulas)
2) correct the variance for the grouping bias
3) compute the skewness by dividing the grouped third moment by the corrected grouped second moment.
However, you may want to ponder the circumstances under which the corrections apply. For example, you might see the discussion of the corrections in Kendall and Stuart, or maybe consult 
M. G. Kendall (1938),
The Conditions under which Sheppard's Corrections are Valid
Journal of the Royal Statistical Society,
Vol. 101, No. 3, p592-605  
[Even so, dividing an unbiased numerator by an unbiased denominator doesn't itself lead to an unbiased ratio, even when they're independent, so if an actually unbiased ratio is of interest, further analysis would be needed -- but we don't generally concern ourselves with that when dealing with ordinary sample skewness either.]
