[R] using reorder in "dotplot"
David Winsemius
dwinsemius at comcast.net
Mon Mar 22 22:41:33 CET 2010
On Mar 22, 2010, at 5:17 PM, Veerappa Chetty wrote:
> Hi ,
> Name
> rate
>
> HEALTHALLIANCE HOSPITALS, INC -1.06211747
> MOUNT AUBURN HOSPITAL 0.50960291
> STURDY MEMORIAL HOSPITAL 2.64233232
> LAWRENCE GENERAL HOSPITAL 2.15628558
> CAMBRIDGE HEALTH ALLIANCE 1.23623144
>
> I would like use "reorder" in the "dotplot" function. I want the
> dots in
> the increasing order. I know how to do it using "dotchart".
The Posting Guide also suggests that you offer code that constructs a
dummy dataset if you cannot provide a representative real dataset.
With the barley dataset you can see the effects of sorting a factor
variable with this code:
> dotplot(variety ~ yield | year * site, data=barley)
>
> str(barley)
'data.frame': 120 obs. of 4 variables:
$ yield : num 27 48.9 27.4 39.9 33 ...
$ variety: Factor w/ 10 levels "Svansota","No. 462",..: 3 3 3 3 3 3
7 7 7 7 ...
$ year : Factor w/ 2 levels "1932","1931": 2 2 2 2 2 2 2 2 2 2 ...
$ site : Factor w/ 6 levels "Grand Rapids",..: 3 6 4 5 1 2 3 6 4
5 ...
> levels(barley$site)
[1] "Grand Rapids" "Duluth" "University Farm"
"Morris" "Crookston" "Waseca"
> levels(barley$site) <- sort(levels(barley$site))
> dotplot(variety ~ yield | year * site, data=barley)
> levels(barley$variety) <- names(sort(with(barley , tapply(yield,
variety, mean) )))
> levels(barley$variety)
[1] "Svansota" "Manchuria" "No. 475"
"Velvet" "Glabron" "Peatland"
[7] "No. 462" "No. 457" "Wisconsin No. 38" "Trebi"
> dotplot(variety ~ yield | year * site, data=barley)
>
> I would appreciate help. Also I could not easily find a method to
> post data
> when I seek help in the posting guide.
I was under the impression that files with extension .txt would pass
the server filter. I am attaching two copies of the same file, one
with .txt and the other with .csv as extensions. My experience tells
me that only the .txt file will pass.
-- David
test.csv
-------------- next part --------------
name.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: name.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100322/6e06df89/attachment.txt>
-------------- next part --------------
> Thanks.
> Chetty
> --
> Professor of Family Medicine
> Boston University
> Tel: 617-414-6221, Fax:617-414-3345
> emails: chettyvk at gmail.com,vchetty at bu.edu
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
More information about the R-help
mailing list