Hello, I hope to plot my data in a dot diagram, something like the output of the last example of layout function in graphics package. The only difference is that I need the rectangle in histogram is replaced by dot. Thanks in advance. Best wishes, Jinsong Zhao
hist() returns an object that contains information for you to construct what you want, I believe, so you should be able do something like: obj <- hist(..., plot=FALSE) and contruct your dot diagram based on obj. See the `Value' section of ?hist. Andy From: Jinsong Zhao> > Hello, > > I hope to plot my data in a dot diagram, something like the > output of the last example of layout function in graphics > package. The only difference is that I need the rectangle in > histogram is replaced by dot. > > Thanks in advance. > > Best wishes, > > Jinsong Zhao > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
Hi, I am wondering whether there is a function that could plot a dot diagram like the output of following code. Thanks in advance! Best wishes! Jinsong --------->my dirty code here<--------- mydata <- c(26,26,27,27,27,27,28,28,28,28,28,28,28,28,28, 28,28,28,28,29,29,29,29,29,29,29,29,29,29,29, 30,30,30,30,30,30,30,30,31,31,31,31,32,33,33, 33,34,34,35,43) my.dot.plot <- function(x, ...) { x.table <- table(x) x.x <- as.numeric(names(x.table)) x.y <- as.numeric(x.table) n <- length(x.x) x.final <- NULL for (i in 1:n) { tmp <- data.frame(x=rep(x.x[i], x.y[i]), y=1:x.y[i]) x.final <- rbind(x.final, tmp) } plot(x.final, yaxt="n", ylab="", pch=19, frame.plot=FALSE, ...) } my.dot.plot(mydata, xlab ="speed", xlim=c(25,45))
A basic implementation of this is the "dots" function in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Jinsong Zhao > Sent: Sunday, April 09, 2006 12:07 AM > To: R-help > Subject: [R] dot diagram > > Hi, > > I am wondering whether there is a function that could plot a > dot diagram like the output of following code. > > Thanks in advance! > > Best wishes! > > Jinsong > > > --------->my dirty code here<--------- > > mydata <- c(26,26,27,27,27,27,28,28,28,28,28,28,28,28,28, > 28,28,28,28,29,29,29,29,29,29,29,29,29,29,29, > 30,30,30,30,30,30,30,30,31,31,31,31,32,33,33, > 33,34,34,35,43) > > my.dot.plot <- function(x, ...) { > x.table <- table(x) > x.x <- as.numeric(names(x.table)) > x.y <- as.numeric(x.table) > n <- length(x.x) > x.final <- NULL > for (i in 1:n) { > tmp <- data.frame(x=rep(x.x[i], x.y[i]), y=1:x.y[i]) > x.final <- rbind(x.final, tmp) > } > plot(x.final, yaxt="n", ylab="", pch=19, frame.plot=FALSE, ...) } > > my.dot.plot(mydata, xlab ="speed", xlim=c(25,45)) > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >