Hi Gundala,
You have to reorder the points, like below:

#(your code ...)
g <- cbind(x,g.pdf)[order(x),]
points(x=[,1],y=g[,2],type='l',col="red")

Cheers,
gary

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Gundala Viswanath
Sent: Monday, August 04, 2008 9:50 AM
To: [EMAIL PROTECTED]
Subject: [R] Howto Smooth a Curve Created with the Point Function


Hi all,

I have this figure:

 http://docs.google.com/Doc?id=df5zfsj4_103rjt2v4d5

created with the following steps:

> x
  [1]  90.4  57.8  77.0 103.7  55.4 217.5  68.1  85.3 152.0 113.0  97.1
89.9
 [13]  68.1  83.7  77.4  34.5 104.9 170.3  88.6  88.1 108.8  77.4  85.6
82.7
 [25]  81.3 108.0  49.5  71.0  85.7  99.3 203.5 275.9  51.1  84.8  16.5
72.6
 [37] 160.5 158.3 136.7 140.0  98.4 116.1 177.0 168.7 208.0 219.3  90.5
119.7
 [49]  72.9 138.4  98.6  56.0 151.6 230.0  82.0  65.6  83.0 106.9 141.3
103.9
 [61]  76.0  90.6  72.9  85.5  70.5 134.3 129.5 130.9 187.1 131.4  57.7
179.7
 [73]  89.7 126.1 124.4 103.2 111.8 143.1  59.4  85.3 122.8 100.0 158.4
188.2
 [85]  91.9  90.0  74.5  70.2 105.8  90.0  96.6 109.5 176.8 145.1 126.2
215.9
 [97] 103.4 154.3  84.8 112.8 119.8 111.9 107.6 114.3 198.7  98.2 187.6
196.7
[109] 138.5 146.1  75.0  80.0 147.7 171.3  90.1  58.1 109.3 136.6  91.5
93.8
[121]  79.4  71.8

> xhist <- hist(x,col="blue", xlab="Exp Level",freq=FALSE)
> alpha <- 6.352082
> beta   <- 17.84647
> g.pdf <- dgamma(x,shape=alpha,scale=beta)
> points(x,g.pdf,col="red",type='l')  ## problem here

My question is:

Why the command "points" DOES NOT create smooth red curve
as we expected? How can I resolve this problem?

I specifically want to use the dgamma
function with the learned parameter (alpha,beta).

That's why I don't use this command:
> lines(density(x),add=T, col="red")


- Gundala Viswanath
Jakarta - Indonesia

______________________________________________
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.
--------------------------------------------------------

This message w/attachments (message) may be privileged, confidential or 
proprietary, and if you are not an intended recipient, please notify the 
sender, do not use or share it and delete it. Unless specifically indicated, 
this message is not an offer to sell or a solicitation of any investment 
products or other financial product or service, an official confirmation of any 
transaction, or an official statement of Merrill Lynch. Subject to applicable 
law, Merrill Lynch may monitor, review and retain e-communications (EC) 
traveling through its networks/systems. The laws of the country of each 
sender/recipient may impact the handling of EC, and EC may be archived, 
supervised and produced in countries other than the country in which you are 
located. This message cannot be guaranteed to be secure or error-free. This 
message is subject to terms available at the following link: 
http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you 
consent to the foregoing.

______________________________________________
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.

Reply via email to