try the following:
x <- rnorm(1000)
ks <- ksmooth(x, kernel = "normal", bandwidth = bandwidth.nrd(x))
hist(x, prob = TRUE, ylab = "density", col = 0)
lines(ks$x, ks$y, col = 6, lwd = 3)
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Liu Zhigang" <email.lzg@gmail.com>
To: <s-news@lists.biostat.wustl.edu>
Sent: Monday, May 29, 2006 9:32 AM
Subject: [S] about S-plus graph
I am working with basic statistical graph.
Anybody can tell me how to make density line with histogram according
S-Plus
command?
I can get it on menu selection, but I want to using it in my script.
thank you
Liu Zhigang
Jilin University, Jilin, China
email.lzg@gmail.com
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
|