Reputation: 313
I have data looks like:
zip ID count
230 B 12
230 A 10
230 C 9
230 D 5
270 C 10
270 A 9
270 B 8
290 C 9
290 A 8
290 B 6
zip
and ID
are factor and count
is numeric. ID is uniquely associated with count. Within each level of zip, count is in desc order.
How can I create cumulative percentage graphs by each level of zip
for count
(in this case, I need 3 graphs in one window) and at the same time ticking the x-axis using ID
? Also, the x-axis will keep the desc order or count (which means, the largest percentage goes first).
So far I read that ggplot2 has ecdf built-in, but I don't know how to generate multiple graphs there. I tried
p<-qplot(dat,stat='ecdf',geom='count')+facet_wrap(~zip,ncol=10)
But it didn't work at all.
Can anyone give me a hint?
Upvotes: 1
Views: 1600
Reputation: 263301
ggplot(dat, aes(x=count) )+stat_ecdf()+facet_wrap(~zip,ncol=10)
(Although the ncol argument seems to get ignored.)
Upvotes: 2