1

According to Plotting CCDF of walking durations, I generated the ccdf plot like this:

ccdf<-function(views,density=FALSE)
  {
    freq = table(views)
    X = rev(as.numeric(names(freq)))
    Y =cumsum(rev(as.list(freq)));
    data.frame(x=X,count=Y)
  }
library(ggplot2)
qplot(x,count,data=ccdf(views),log='xy')

ccdf

The Y axis = counts of x value, but I want to get the Y = P[X >= x], how can I do that?

Community
  • 1
  • 1
manxing
  • 3,165
  • 12
  • 45
  • 56

1 Answers1

0

I don't know exactly what your data looks like but it sounds like you want:

ccdf<-function(views,density=FALSE)
  {
    freq = table(views)
    X = rev(as.numeric(names(freq)))
    Y =cumsum(as.list(freq));          #not reversed
    Y=(max(Y)-Y)/max(Y)                #proportion, beware recursion!
    data.frame(x=X,Cum.Prop=Y)         #name change  
  }
qplot(x,Cum.Prop ,data=ccdf(views),log='xy')

If you tell me a bit more about your views variable I can make sure that it is working right.

Seth
  • 4,745
  • 23
  • 27