Hi, is there a way to plot distribution curves (say normal or chi sq etc) from within R? For example I looked up the *chisq family of functions but I'm not sure as to how I would use them to generate a plot of the chi sq distribution (for arbitrary d.o.f). Thanks, ------------------------------------------------------------------- Rajarshi Guha <rajarshi at presidency.com> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE ------------------------------------------------------------------- Did you hear that two rabbits escaped from the zoo and so far they have only recaptured 116 of them?
Hallo On 1 Sep 2003 at 16:25, Rajarshi Guha wrote:> Hi, > is there a way to plot distribution curves (say normal or chi sq > etc) > from within R? > > For example I looked up the *chisq family of functions but I'm not > sure as to how I would use them to generate a plot of the chi sq > distribution (for arbitrary d.o.f).Something like that plot(seq(-3,3,.1),dnorm(seq(-3,3,.1)),type="l") plot(seq(0,20,.1),dchisq(seq(0,20,.1),5),type="l")> > Thanks, > > ------------------------------------------------------------------- > Rajarshi Guha <rajarshi at presidency.com> <http://jijo.cjb.net> GPG > Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE > ------------------------------------------------------------------- > Did you hear that two rabbits escaped from the zoo and so far they > have only recaptured 116 of them? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-helpCheers Petr Pikal petr.pikal at precheza.cz
> -----Original Message----- > From: Petr Pikal [mailto:petr.pikal at precheza.cz] > Sent: 03 September 2003 13:57 > To: rajarshi at presidency.com > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] plotting a distribution curves > > > Hallo > > On 1 Sep 2003 at 16:25, Rajarshi Guha wrote: > > > Hi, > > is there a way to plot distribution curves (say normal or chi sq > > etc) > > from within R? > > > > For example I looked up the *chisq family of functions but I'm not > > sure as to how I would use them to generate a plot of the chi sq > > distribution (for arbitrary d.o.f). > > Something like that > > plot(seq(-3,3,.1),dnorm(seq(-3,3,.1)),type="l") > plot(seq(0,20,.1),dchisq(seq(0,20,.1),5),type="l")Or using curve (see ?curve) curve(dnorm(x,1,2),-4,6) curve(dchisq(x,5),0,20) HTH Thomas> > > > > > Thanks, > > > > ------------------------------------------------------------------- > > Rajarshi Guha <rajarshi at presidency.com> <http://jijo.cjb.net> GPG > > Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE > > ------------------------------------------------------------------- > > Did you hear that two rabbits escaped from the zoo and so far they > > have only recaptured 116 of them? > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > Cheers > Petr Pikal > petr.pikal at precheza.cz > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >--- Thomas Hotz Research Associate in Medical Statistics University of Leicester United Kingdom Department of Epidemiology and Public Health 22-28 Princess Road West Leicester LE1 6TP Tel +44 116 252-5410 Fax +44 116 252-5423 Division of Medicine for the Elderly Department of Medicine The Glenfield Hospital Leicester LE3 9QP Tel +44 116 256-3643 Fax +44 116 232-2976
Rajarshi Guha <rajarshi at presidency.com> wrote: is there a way to plot distribution curves (say normal or chi sq etc) from within R? For example I looked up the *chisq family of functions but I'm not sure as to how I would use them to generate a plot of the chi sq distribution (for arbitrary d.o.f). Perhaps the most obvious way: x <- seq(0, 30, length=101) plot(x, dchisq(x, df=8)) Another way: curve(dchisq(x,df=8), from=0, to=30) As someone has recently noted, code that depends on the textual form of something is often subtly wrong, which is why I think that "curve" and similar functions are best avoided. A third way that is better than "curve" is plot(function(x) dchisq(x,df=8), from=0, to=30) in which the name of the argument x no longer matters. This can of course be used with any function, not just a c* function.