[R] How to plot two cumulative frequency graph together
David Winsemius
dwinsemius at comcast.net
Fri Mar 19 14:28:34 CET 2010
On Mar 18, 2010, at 11:00 PM, Gundala Viswanath wrote:
> Dear masters,
>
> I have data that looks like this:
>
> #val Freq1 Freq2
Get rid of the # at the beginning of the file. It wiil be interpreted
as a comment rather than a header.
> 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.
>
> What's the right way to approach this?
Not a very interesting plot because of that huge value of "val" at the
end of that data. and it dose not look like a proper ECDF because the
val values are not sorted.
conn= url("http://dpaste.com/173536/plain/")
dfrm <- read.table(file=conn, skip=1)
names(dfrm) <- c("val","Freq1","Freq2")
plot(dfrm$val,cumsum(dfrm$Freq1),type="s")
So I would clean up the data by ordering on "val" and maybe
reconsidering the range of plotted data.
May also want to set the ylim on the basis of the sum of Freq2 because
it is higher.
Use lines() with a step type for the second series.
>
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list