[R] dotchart for matrix data
e-letter
inpost at gmail.com
Sat Dec 18 13:01:40 CET 2010
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. The
objective is to be able to create a dot chart where each row is
labelled according to the row names in the 'category' column and two
columns can be selected, e.g. 'values1' and 'values2'. Then I tried:
> testdot1<-testdot[,1]
> testdot2<-testdot[,2]
> testdot3<-testdot[,3]
> dotchart(c(testdot2,testdot3),labels=testdot1)
A graph is produced, but not as expected. Instead of 4 rows labelled
(descending order from top row) a,b,c,d, and each row containing two
data points, the graph shows 8 rows (?) with the top 4 rows
un-labelled and the bottom 4 rows labelled (descending order) d,c,b,a
and each row shows only 1 datum point.
How do I specify the order of labelling of the rows?
How do I write correct commands to obtain a dot chart with 4 rows,
each row containing the two (or if required three) data points?
Thanks in advance.
More information about the R-help
mailing list