On 13-Jul-10 22:21:29, Melissa Peters wrote: > Hello, > > 1. I have a number of snow depth measurements (centimeters depth) that > were acquired in a row (linear transect). > > A: I am trying to plot the probability density function (PDF) of these > points. When I use the "dnorm" command and line type = points, the PDF > is displayed correctly. When I change the line type = line, it displays > the PDF curve with numerous lines connecting multiple of the points > together rather than just one line connecting the points in sequence. I > have noticed in some online help tutorials the use of the "seq" > command, but when I employ this it simply flattens my PDF curve to a > straight line at 0% probability. Is there something I am missing? > >> plot(Snow,dnorm(Snow,mean=26.61,sd=14.179),type="l")
On just this point: From your description, it seems likely that the values in "Snow" are not in increasing order. Hence, when you plot usinf type="l", ir will take the points in the order in which they are found in "Snow" and so the lines connecting successive points will jump about all over the place. You can cure this by sorting "Snow" into increasing order: plot(sort(Snow),dnorm(sort(Snow),mean=26.61,sd=14.179),type="l") should do it. However, this may not look as nice as you would like, if the spacings between successive sorted values are very irregular. It may look better if you plot "Snow" as points, and then add lines drawn to a regular sequence. Hence something like S0 <- ((max(Snow) - min(Snow))/100)*(-0.05+(0:101)) plot(Snow,dnorm(Snow,mean=26.61,sd=14.179),pch="+",col="blue") lines(S0,dnorm(S0,mean=26.61,sd=14.179),col="green") may look better. Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 14-Jul-10 Time: 00:08:32 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.