using reorder in "dotplot"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

using reorder in "dotplot"

Veerappa Chetty
   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".

I would appreciate help. Also I could not easily find a method to post data
when I seek help in the posting guide.
Thanks.
Chetty
--
Professor of Family Medicine
Boston University
Tel: 617-414-6221, Fax:617-414-3345
emails: [hidden email],[hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: using reorder in "dotplot"

David Winsemius

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




name.txt




> Thanks.
> Chetty
> --
> Professor of Family Medicine
> Boston University
> Tel: 617-414-6221, Fax:617-414-3345
> emails: [hidden email],[hidden email]
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.

name.txt (101 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: using reorder in "dotplot"

djmuseR
In reply to this post by Veerappa Chetty
Hi:

Is this what you are after?  (df is the data frame name)

library(lattice)
dotplot(reorder(Name, rate) ~ rate, data = df)

HTH,
Dennis

On Mon, Mar 22, 2010 at 2:17 PM, Veerappa Chetty <[hidden email]> 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".
>
> I would appreciate help. Also I could not easily find a method to post data
> when I seek help in the posting guide.
> Thanks.
> Chetty
> --
> Professor of Family Medicine
> Boston University
> Tel: 617-414-6221, Fax:617-414-3345
> emails: [hidden email],[hidden email]
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.