You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A table is printed out with some great data for analysis:
28
26
@@ -32,55 +30,60 @@ A table is printed out with some great data for analysis:
32
30
| Poisonous | Convex | Smooth | Brown | Bruises | Pungent | Free | Close | Narrow | Black | Enlarging | Equal | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Scattered | Urban |
33
31
| Edible | Convex | Smooth | Yellow | Bruises | Almond | Free | Close | Broad | Black | Enlarging | Club | Smooth | Smooth | White | White | Partial | White | One | Pendant | Brown | Numerous | Grasses |
34
32
| Edible | Bell | Smooth | White | Bruises | Anise | Free | Close | Broad | Brown | Enlarging | Club | Smooth | Smooth | White | White | Partial | White | One | Pendant | Brown | Numerous | Meadows |
35
-
| Poisonous | Convex | Scaly | White | Bruises | Pungent | Free | Close | Narrow | Brown | Enlarging | Equal | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Scattered | Urban |
36
-
33
+
| Poisonous | Convex | Scaly | White | Bruises | Pungent | Free | Close | Narrow | Brown | Enlarging | Equal | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Scattered | Urban
34
+
| Edible | Convex |Smooth | Green | No Bruises| None |Free | Crowded | Broad | Black | Tapering | Equal | Smooth | Smooth | White | White | Partial | White | One | Evanescent | Brown | Abundant | Grasses
35
+
|Edible | Convex | Scaly | Yellow | Bruises | Almond | Free | Close | Broad | Brown | Enlarging | Club | Smooth | Smooth | White | White | Partial | White | One | Pendant | Black | Numerous | Grasses
36
+
37
37
Right away, you notice that all the data is textual. You will have to convert this data to be able to use it in a chart. Most of the data, in fact, is represented as an object:
Voila, a pie chart showing the proportions of this data according to these two classes of mushrooms. It's quite important to get the order of the labels correct, especially here, so be sure to verify the order with which the label array is built!
86
89
@@ -92,26 +95,29 @@ A somewhat more visually interesting pie chart is a donut chart, which is a pie
92
95
93
96
Take a look at the various habitats where mushrooms grow:
94
97
95
-
```python
96
-
habitat=mushrooms.groupby(['habitat']).count()
97
-
habitat
98
+
```r
99
+
habitat=mushrooms %>%
100
+
group_by(habitat) %>%
101
+
summarise(count=n())
102
+
View(habitat)
98
103
```
99
-
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:
109
117
110
-
fig.gca().add_artist(center_circle)
111
-
112
-
plt.title('Mushroom Habitats')
113
-
114
-
plt.show()
118
+
```r
119
+
library(webr)
120
+
PieDonut(habitat, aes(habitat, count=count))
115
121
```
116
122
117
123

@@ -123,10 +129,10 @@ Donut charts can be tweaked in several ways to change the labels. The labels in
123
129
Now that you know how to group your data and then display it as a pie or donut, you can explore other types of charts. Try a waffle chart, which is just a different way of exploring quantity.
124
130
## Waffles!
125
131
126
-
A 'waffle' type chart is a different way to visualize quantities as a 2D array of squares. Try visualizing the different quantities of mushroom cap colors in this dataset. To do this, you need to install a helper library called [PyWaffle](https://pypi.org/project/pywaffle/) and use Matplotlib:
132
+
A 'waffle' type chart is a different way to visualize quantities as a 2D array of squares. Try visualizing the different quantities of mushroom cap colors in this dataset. To do this, you need to install a helper library called [waffle](https://r-charts.com/part-whole/waffle-chart-ggplot2/) and use it to generate your visualization:
Create a basic scatterplot to show the relationship between the price per pound of honey and its U.S. state of origin. Make the `y` axis tall enough to display all the states:
0 commit comments