|
|
@ -59,6 +59,7 @@ The output is:
|
|
|
|
Take this data and convert the 'class' column to a category:
|
|
|
|
Take this data and convert the 'class' column to a category:
|
|
|
|
|
|
|
|
|
|
|
|
```r
|
|
|
|
```r
|
|
|
|
|
|
|
|
library(dplyr)
|
|
|
|
grouped=mushrooms %>%
|
|
|
|
grouped=mushrooms %>%
|
|
|
|
group_by(class) %>%
|
|
|
|
group_by(class) %>%
|
|
|
|
summarise(count=n())
|
|
|
|
summarise(count=n())
|
|
|
@ -96,6 +97,7 @@ A somewhat more visually interesting pie chart is a donut chart, which is a pie
|
|
|
|
Take a look at the various habitats where mushrooms grow:
|
|
|
|
Take a look at the various habitats where mushrooms grow:
|
|
|
|
|
|
|
|
|
|
|
|
```r
|
|
|
|
```r
|
|
|
|
|
|
|
|
library(dplyr)
|
|
|
|
habitat=mushrooms %>%
|
|
|
|
habitat=mushrooms %>%
|
|
|
|
group_by(habitat) %>%
|
|
|
|
group_by(habitat) %>%
|
|
|
|
summarise(count=n())
|
|
|
|
summarise(count=n())
|
|
|
@ -116,6 +118,7 @@ The output is:
|
|
|
|
Here, you are grouping your data by habitat. There are 7 listed, so use those as labels for your donut chart:
|
|
|
|
Here, you are grouping your data by habitat. There are 7 listed, so use those as labels for your donut chart:
|
|
|
|
|
|
|
|
|
|
|
|
```r
|
|
|
|
```r
|
|
|
|
|
|
|
|
library(ggplot2)
|
|
|
|
library(webr)
|
|
|
|
library(webr)
|
|
|
|
PieDonut(habitat, aes(habitat, count=count))
|
|
|
|
PieDonut(habitat, aes(habitat, count=count))
|
|
|
|
```
|
|
|
|
```
|
|
|
|