Re: [R] A plot of factor data?

From: Sang Chul Choi <Choi_at_biology.rutgers.edu>
Date: Fri, 02 May 2008 11:05:46 -0400

Thank you, Bert!

I have a question one more. I have found out that "mosaic" function of "vcd" package is more interesting since I want to color different cells.

The question is how to make x axis label to be vertical not horizontal. I tried "las" or some other options in "par" but I could not change it. Here is an example.



library(vcd)
music = c(10, 5, 15, 20)
dim(music) = c(2,2)
dimnames(music) = list(Age=c("old", "young"), Listen=c("yes","no")) mosaic(music, split_vertical=TRUE)

The "Age" names are "old", and "young." I want them to be vertical rather than horizontal since I have too many columns.

Thank you,

Sang Chul

On May 1, 2008, at 7:27 PM, Bert Gunter wrote:

> ?mosaicplot
>
> -- Bert Gunter
>
> -----Original Message-----
> From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org
> ] On
> Behalf Of Sang Chul Choi
> Sent: Thursday, May 01, 2008 4:09 PM
> To: r-help_at_r-project.org
> Subject: [R] A plot of factor data?
>
> Hi,
>
> I am wondering if there is a way to plot proportions of factors. I
> tried to find plot functions for those but in vain.
>
> For example, I have a data like this where column "a" has 10 of "0"s
> and 15 of "1"s, and column "b" has 5 and 20.
>
>> x <-
> data
> .frame
> ("a"=factor(c(rep(0,10),rep(1,15))),b=factor(c(rep(0,5),rep(1,20))))
>> summary(x)
> a b
> 0:10 0: 5
> 1:15 1:20
>
> I want to have a plot like:
>
> |-----|
> | | <--- proportion of "0"
> | |
> |-----|
> | |
> | | <--- proportion of "1"
> | |
> |-----|
>
> column "a"
>
> |-----|
> | | <--- proportion of "0"
> |-----|
> | |
> | |
> | | <--- proportion of "1"
> | |
> |-----|
>
> column "b"
>
> Is there anybody who can do this easily? I appreciate any help.
>
> Thank you,
>
> Sang Chul
>
> ______________________________________________
> 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.
>



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. Received on Fri 02 May 2008 - 16:43:11 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 02 May 2008 - 18:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive