Howto plot two cumulative frequency graph together

Posted by neversaint on Stack Overflow See other posts from Stack Overflow or by neversaint
Published on 2010-03-19T03:27:15Z Indexed on 2010/03/19 3:31 UTC
Read the original article Hit count: 189

Filed under:
|
|
|

I have data that looks like this:

#val  Freq1 Freq2
0.000 178 202
0.001 4611 5300
0.002 99 112
0.003 26 30
0.004 17 20
0.005 15 20
0.006 11 14
0.007 11 13
0.008 13 13
...many more lines..

Full data can be found here: http://dpaste.com/173536/plain/

What I intend to do is to have a cumulative graph with "val" as x-axis with "Freq1" & "Freq2" as y-axis, plot together in 1 graph.

I have this code. But it creates two plots instead of 1.

dat <- read.table("stat.txt",header=F);
val<-dat$V1
freq1<-dat$V2
freq2<-dat$V3

valf1<-rep(val,freq1)
valf2<-rep(val,freq2)

valfreq1table<- table(valf1)
valfreq2table<- table(valf2)
cumfreq1=c(0,cumsum(valfreq1table))
cumfreq2=c(0,cumsum(valfreq2table))

plot(cumfreq1, ylab="CumFreq",xlab="Loglik Ratio")
lines(cumfreq1)
plot(cumfreq2, ylab="CumFreq",xlab="Loglik Ratio")
lines(cumfreq2)

What's the right way to approach this?

© Stack Overflow or respective owner

Related posts about r

    Related posts about statistics