[R] weighted cumulative distribution with ggplot2

David Winsemius dwinsemius at comcast.net
Mon Oct 8 18:18:54 CEST 2012


On Oct 8, 2012, at 8:01 AM, Francesco wrote:

> I think I have my answer... ggplot2 uses ecdf which does NOT allow
> weightings...
> so there is no warning or error, but still the resulting plot do not
> take into account the command weight=weight

It was completely unclear why you expected ggplot to use ' ewcdf' when you gave a command to use 'ecdf'.


> 
> Hope that helps someone, just in case ;-)
> 
> On 8 October 2012 15:40, Francesco <cariboupad at gmx.fr> wrote:
>> Dear all,
>> 
>> I am trying to draw a weighted cumulative distribution (as defined
>> here http://rss.acs.unt.edu/Rdoc/library/spatstat/html/ewcdf.html)
>> with ggplot2
>> 
>> however the syntax
>> 
>> temp<-qplot(X,weight=weight,data=data,stat = "ecdf", geom =
>> "step",colour=factor(year))
>> 
>> seems not to produce exactly the right figure (the values seems higher
>> at some points)... I am wrong in the weight definition?
>> 
>> The data is like the following
>> 
>> X     Weight Year
>> 0      2         2001
>> 0      1         2001
>> 1      5         2001
>> 2      1         2001
>> 2      3         2001
>> 2      2         2002
>> 3.. etc
>> 
>> Any ideas ?
>> Many thanks in advance
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list