Skip to content

Commit

Permalink
remove mosaicplot examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jtr13 authored Oct 7, 2019
1 parent 29821cb commit c938b83
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions mosaic.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ mosaic(Favorite ~ Age + Music,

It is best to draw mosaic plots incrementally: start with splitting on one variable and then add additional variables one at a time. The full mosaic plot will have one split per variable.

Important: if your data is in a data frame (see above), **the count column must be called `Freq`**.
Important: if your data is in a data frame, as in the example below, **the count column must be called `Freq`**. (Tables and matrices also work, see `?vcd::structable` for more details.)

Also note that all of these plots are drawn with `vcd::mosaic()` not the base R function, `mosaicplot()`.

The data:
``` {r}
df
```

Split on `Age` only:

Expand Down Expand Up @@ -140,19 +147,6 @@ mosaic(Favorite ~ Age + Music,
```



## Mosaic using base R

```{r message=FALSE}
library(vcdExtra)
mosaicplot(xtabs(count ~ lake + sex, data=Alligator), main="")
```

```{r}
mosaicplot(xtabs(Freq ~ Favorite + Age + Music, data=df), main="",
dir=c('h', 'v', 'v'))
```

### Mosaic using vcd::doubledecker

```{r}
Expand Down

0 comments on commit c938b83

Please sign in to comment.