[R] number to volume weighted distribution

Duncan Murdoch murdoch.duncan at gmail.com
Fri Nov 24 12:35:51 CET 2017

On 24/11/2017 6:27 AM, PIKAL Petr wrote:
> Dear all
> Strictly speaking it is not R question but as you are the most capable persons I know I give it a try.
> I am strugling with recalculation of number weighted to volume weighted distribution.
> Suppose I have objects (cubes) with size
> x<- c(rep(10,20), rep(100, 10), rep(300,5))
> I can get
> plot(ecdf(x))
> or the number weighted average
> mean(x)
> [1] 77.14286
> or volume weighted average
> weighted.mean(x, (x/sum(x^3)))
> [1] 204.4444
> However I am struggling with volume weighted ecdf.
> Can you please give me some hints?

I believe base R doesn't have a function for this, but Google says it 
exists in a couple of packages:  spatstat, Hmisc.  But you seem to be 
asking about a definition rather than a function:  it is obtained simply 
by normalizing the weights to sum to 1, then evaluating cumulative sums 
of them.

Duncan Murdoch

More information about the R-help mailing list