[R] dotchart for matrix data
David Winsemius
dwinsemius at comcast.net
Sat Dec 18 21:32:18 CET 2010
On Dec 18, 2010, at 1:27 PM, e-letter wrote:
> On 18/12/2010, Peter Ehlers <ehlers at ucalgary.ca> wrote:
>> On 2010-12-18 07:50, e-letter wrote:
>>>> Ben Bolker
>>>> Sat, 18 Dec 2010 07:07:24 -0800
>>
>> [... snip ...]
>>
>>> 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?
>>
>> That looks an awful lot like what lattice's dotplot would
>> produce. So: have you tried dotplot() as Ben has suggested?
>>
>
> For the benefit of other novices, this is what I did (gnu/linux):
>
> sign-in to a command terminal as root
> start R
> install.packages("reshape2")
>
> In another terminal as normal user
>
> require(reshape2)
> mdot<-melt(testdot)
> dotplot(value~category,groups=variable,data=mdot)
>
> The resultant graph shows the categories on the abscissa and there
> does not seem to be a way of selecting two columns from the original
> matrix. It is not like the graph cited in the hyperlink quoted above,
> but at least I have successfully followed instructions!
If you want to see a worked example of a dotplot that has two separate
data series on the same set of lines then look at Fig 10.18 in
Sarkar's "Lattice". The illustration and code are all at the book's
website. I don't think you did a very good job of explaining in text
what you expected to see (at least on my reading of it more than once)
but this may do what you hoped:
dotplot(as.character(mdot$category) ~ mdot$value, labels=mdot$variable)
>
> I changed the axes with the command:
>
> dotplot(category~value,groups=variable,data=mdot)
>
> I believe there is a command to select only certain rows of data which
> I think will achieve the desired graph, if unable I'll ask again, so
> thank you all.
>
> ______________________________________________
> R-help at 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list