Karsten Weinert
2009-May-04 15:44 UTC
[R] mosaic plot with two factors and one continous variable
Hello, my dataset is already aggregated: I have two categorical variables, say "continent" and "country" and one non-negative metric variable "population". Now I would like to produce a mosaic plot which uses "population" to determine how large each area of the plot is. In other words, I fail to find out - how to use the mosaic function of the vcd package without using table, - or I do not know how to convert my dataset into a table (as.table fails) As an example, here a simple dataset: Continent; Country; Population Europe; France; 65 Europe; Germany; 80 Africa; Algeria; 32 .... Can you help me to get started? Kind regards, Karsten. [[alternative HTML version deleted]]
Achim Zeileis
2009-May-04 16:37 UTC
[R] mosaic plot with two factors and one continous variable
On Mon, 4 May 2009, Karsten Weinert wrote:> Hello, > my dataset is already aggregated: I have two categorical variables, say > "continent" and "country" and one non-negative metric variable "population". > Now I would like to produce a mosaic plot which uses "population" to > determine how large each area of the plot is. > > In other words, I fail to find out > - how to use the mosaic function of the vcd package without using table, > - or I do not know how to convert my dataset into a table (as.table fails) > > As an example, here a simple dataset: > > Continent; Country; Population > Europe; France; 65 > Europe; Germany; 80 > Africa; Algeria; 32 > .... > > Can you help me to get started?You can create the tables by xtabs(Population ~ Continent, data = mydata) etc. which can then be visualized using mosaic() in the usual way. hth, Z> Kind regards, > Karsten. > > [[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. > >