Hello,
Thanks to Frank Harrell and Naomi Robbins for letting me know about
reorder.factor(). Using this function simplifies the command somewhat.
Instead of using the command
dotplot(ordered(Y.labels, levels = Y.labels[order(Var)]) ~ Var,
data = dum.df)
you can use the command
dotplot(reorder.factor(Y.labels, Var) ~ Var, data = dum.df)
(Of course I'm assuming the variables Y.labels and Var are directly
accessible. If they are not, then you'd have to type dum.df$Y.labels
and dum.df$Var.)
It looks to me like you have to use reorder.factor() from the command
line; I don't think it is available in the menu. In fact, I don't see
anything on the menu to even let you set up ordered factors.
Sincerely,
--Steve M.
_____________
| *** | Steven P. Millard, Ph.D.
| * |
| * * * | P robability, TEL: 206-528-4877
| * * * | S tatistics & FAX: 206-528-4802
| * | I nformation E-mail: SMillard@ProbStatInfo.com
| * | Web: www.ProbStatInfo.com
| *** | 7723 44th Avenue NE
|___________| Seattle, WA 98115-5117 USA
***********Original Query*************************************
Hello,
I am using S-PLUS 4.5, Release 2.
On p. 152 of "The Elements of Graphing Data" by William S. Cleveland is
the statement, "Typically, our perception of the distribution of the
values on a dot plot is enhanced by graphing the data ordered from
smallest to largest...One exception is the case in which the labels
have an order...."
Wishing to follow this advice, I have found it somewhat easy to do with
dotchart (an older S-PLUS function that is not a trellis function), but
not as easy to do with dotplot or the menu selection (in fact I think
there is a bug in the menu version). I list an example below.
I find it a bit amusing that there is no argument to dotchart or
dotplot that allows the user to specify ordering. Does anyone know of
a simpler way other than what I am doing to produce the same thing?
Thanks for your time!
As an example, create some variables and a data frame:
Var <- c(1,2,4,3)
Y.labels <- letters[1:4]
dum.df <- data.frame(Var = Var, Y.labels = Y.labels)
If we use the dotchart function with defaults:
dotchart(Var, Y.labels)
then the values are not ordered from smallest to largest, but this is
relatively easy to fix with the following modified command:
> dotchart(rev(sort(Var)), rev(Y.labels[order(Var)]))
If we use the dotplot function with defaults:
dotplot(Y.labels ~ Var, data = dum.df)
then again the values are not ordered from smallest to largest. To fix
this, you can use the following modified command:
dotplot(ordered(Y.labels, levels = Y.labels[order(Var)]) ~ Var,
data = dum.df)
If we use the 2D Graph menu and choose Dotplot, then set Data Set to
dum.df, X Column(s) to Var, Y Column(s) to Y.labels, click on the
Smooth/Sort tab, and set Pre-Sort Data to XY on X, the plot does not
come out correctly.
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|