>Ben Bolker >Sat, 18 Dec 2010 07:07:24 -0800 >David Winsemius <dwinsemius <at> comcast.net> writes: > >> >> >> On Dec 18, 2010, at 7:01 AM, e-letter wrote: >> >> > Readers, >> > >> > I am trying to use the function dotchart. The data is: >> > >> >> testdot >> > category values1 values2 values3 values4 >> > 1 a 10 27 56 709 >> > 2 b 4 46 47 208 >> > 3 c 5 17 18 109 >> > 4 d 6 50 49 308 >> > >> > The following error occurs >> > >> >> dotchart(testdot,groups=testdot[,2]) >> > Error in dotchart(testdot, labels = testdot[, 1], groups = testdot[, >> > 2]) : >> > 'x' must be a numeric vector or matrix >> > >> > According to my understanding (clearly wrong!) of the documentation >> > for dotchart (accessed from the manual in section 'graphics'), columns >> > of data can be selected by 'groups' for subsequent plotting. >> > > Following up on David's response: > > >d <- read.table(textConnection("category values1 values2 values3 values4 >1 a 10 27 56 709 >2 b 4 46 47 208 >3 c 5 17 18 109 >4 d 6 50 49 308"), > header=TRUE) > >## Something like this is probably as close as you can get with >## stock 'dotchart' -- it does *not* (as far as I can tell) put >## different points on the same line, just groups lines >
I am trying to create a chart like this (http://www.b-eye-network.com/images/content/Fig4_3.jpg); so this is not possible using R? >dotchart(as.matrix(d[,-1]),labels=as.character(d[,1])) >dotchart(as.matrix(d[,c("values1","values2")]),labels=as.character(d[,1])) > >## reshaping data: >library(reshape) >mdot <- melt(d) > >## using the lattice package > >library(lattice) >dotplot(value~category,groups=variable,data=mdot) >dotplot(value~variable,groups=category,data=mdot,auto.key=TRUE, > scales=list(y=list(log=10))) > >## you could also use ggplot2 ... > ?ggplot2 No documentation for 'ggplot2' in specified packages and libraries: you could try 'help.search("ggplot2")'; seems I need to retrieve this package first. Thanks for the suggestion. ______________________________________________ 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.