Pour your data into a waffle iron to get ready to cook a waffle chart.
waffle_iron(data, mapping, rows = 8, sample_size = 1, na.rm = T)
A dataframe to feed into the waffle iron
A mapping as produce by aes_d
, aes_d_
or a character vector of a column present in the dataset
The number of rows in the waffle
The proportion of rows to sample the dataset (between 0 and 1). Useful when the dataset is too large to plot correctly.
A boolean flag to automatically remove NAs. Removing NAs will sometimes cause a missing notch in your waffle.
Prepare raw data so it is fit to create a waffle visualisation. The type of data transformation that is required does not gel well with ggplot2 underlying mechanism. The way around this is to provide a function that does the preperation outside of ggplot.
waffle_iron(mpg, aes_d(group = class))
#> y x group
#> 1 1 1 2seater
#> 2 2 1 2seater
#> 3 3 1 2seater
#> 4 4 1 2seater
#> 5 5 1 2seater
#> 6 6 1 compact
#> 7 7 1 compact
#> 8 8 1 compact
#> 9 1 2 compact
#> 10 2 2 compact
#> 11 3 2 compact
#> 12 4 2 compact
#> 13 5 2 compact
#> 14 6 2 compact
#> 15 7 2 compact
#> 16 8 2 compact
#> 17 1 3 compact
#> 18 2 3 compact
#> 19 3 3 compact
#> 20 4 3 compact
#> 21 5 3 compact
#> 22 6 3 compact
#> 23 7 3 compact
#> 24 8 3 compact
#> 25 1 4 compact
#> 26 2 4 compact
#> 27 3 4 compact
#> 28 4 4 compact
#> 29 5 4 compact
#> 30 6 4 compact
#> 31 7 4 compact
#> 32 8 4 compact
#> 33 1 5 compact
#> 34 2 5 compact
#> 35 3 5 compact
#> 36 4 5 compact
#> 37 5 5 compact
#> 38 6 5 compact
#> 39 7 5 compact
#> 40 8 5 compact
#> 41 1 6 compact
#> 42 2 6 compact
#> 43 3 6 compact
#> 44 4 6 compact
#> 45 5 6 compact
#> 46 6 6 compact
#> 47 7 6 compact
#> 48 8 6 compact
#> 49 1 7 compact
#> 50 2 7 compact
#> 51 3 7 compact
#> 52 4 7 compact
#> 53 5 7 midsize
#> 54 6 7 midsize
#> 55 7 7 midsize
#> 56 8 7 midsize
#> 57 1 8 midsize
#> 58 2 8 midsize
#> 59 3 8 midsize
#> 60 4 8 midsize
#> 61 5 8 midsize
#> 62 6 8 midsize
#> 63 7 8 midsize
#> 64 8 8 midsize
#> 65 1 9 midsize
#> 66 2 9 midsize
#> 67 3 9 midsize
#> 68 4 9 midsize
#> 69 5 9 midsize
#> 70 6 9 midsize
#> 71 7 9 midsize
#> 72 8 9 midsize
#> 73 1 10 midsize
#> 74 2 10 midsize
#> 75 3 10 midsize
#> 76 4 10 midsize
#> 77 5 10 midsize
#> 78 6 10 midsize
#> 79 7 10 midsize
#> 80 8 10 midsize
#> 81 1 11 midsize
#> 82 2 11 midsize
#> 83 3 11 midsize
#> 84 4 11 midsize
#> 85 5 11 midsize
#> 86 6 11 midsize
#> 87 7 11 midsize
#> 88 8 11 midsize
#> 89 1 12 midsize
#> 90 2 12 midsize
#> 91 3 12 midsize
#> 92 4 12 midsize
#> 93 5 12 midsize
#> 94 6 12 minivan
#> 95 7 12 minivan
#> 96 8 12 minivan
#> 97 1 13 minivan
#> 98 2 13 minivan
#> 99 3 13 minivan
#> 100 4 13 minivan
#> 101 5 13 minivan
#> 102 6 13 minivan
#> 103 7 13 minivan
#> 104 8 13 minivan
#> 105 1 14 pickup
#> 106 2 14 pickup
#> 107 3 14 pickup
#> 108 4 14 pickup
#> 109 5 14 pickup
#> 110 6 14 pickup
#> 111 7 14 pickup
#> 112 8 14 pickup
#> 113 1 15 pickup
#> 114 2 15 pickup
#> 115 3 15 pickup
#> 116 4 15 pickup
#> 117 5 15 pickup
#> 118 6 15 pickup
#> 119 7 15 pickup
#> 120 8 15 pickup
#> 121 1 16 pickup
#> 122 2 16 pickup
#> 123 3 16 pickup
#> 124 4 16 pickup
#> 125 5 16 pickup
#> 126 6 16 pickup
#> 127 7 16 pickup
#> 128 8 16 pickup
#> 129 1 17 pickup
#> 130 2 17 pickup
#> 131 3 17 pickup
#> 132 4 17 pickup
#> 133 5 17 pickup
#> 134 6 17 pickup
#> 135 7 17 pickup
#> 136 8 17 pickup
#> 137 1 18 pickup
#> 138 2 18 subcompact
#> 139 3 18 subcompact
#> 140 4 18 subcompact
#> 141 5 18 subcompact
#> 142 6 18 subcompact
#> 143 7 18 subcompact
#> 144 8 18 subcompact
#> 145 1 19 subcompact
#> 146 2 19 subcompact
#> 147 3 19 subcompact
#> 148 4 19 subcompact
#> 149 5 19 subcompact
#> 150 6 19 subcompact
#> 151 7 19 subcompact
#> 152 8 19 subcompact
#> 153 1 20 subcompact
#> 154 2 20 subcompact
#> 155 3 20 subcompact
#> 156 4 20 subcompact
#> 157 5 20 subcompact
#> 158 6 20 subcompact
#> 159 7 20 subcompact
#> 160 8 20 subcompact
#> 161 1 21 subcompact
#> 162 2 21 subcompact
#> 163 3 21 subcompact
#> 164 4 21 subcompact
#> 165 5 21 subcompact
#> 166 6 21 subcompact
#> 167 7 21 subcompact
#> 168 8 21 subcompact
#> 169 1 22 subcompact
#> 170 2 22 subcompact
#> 171 3 22 subcompact
#> 172 4 22 subcompact
#> 173 5 22 suv
#> 174 6 22 suv
#> 175 7 22 suv
#> 176 8 22 suv
#> 177 1 23 suv
#> 178 2 23 suv
#> 179 3 23 suv
#> 180 4 23 suv
#> 181 5 23 suv
#> 182 6 23 suv
#> 183 7 23 suv
#> 184 8 23 suv
#> 185 1 24 suv
#> 186 2 24 suv
#> 187 3 24 suv
#> 188 4 24 suv
#> 189 5 24 suv
#> 190 6 24 suv
#> 191 7 24 suv
#> 192 8 24 suv
#> 193 1 25 suv
#> 194 2 25 suv
#> 195 3 25 suv
#> 196 4 25 suv
#> 197 5 25 suv
#> 198 6 25 suv
#> 199 7 25 suv
#> 200 8 25 suv
#> 201 1 26 suv
#> 202 2 26 suv
#> 203 3 26 suv
#> 204 4 26 suv
#> 205 5 26 suv
#> 206 6 26 suv
#> 207 7 26 suv
#> 208 8 26 suv
#> 209 1 27 suv
#> 210 2 27 suv
#> 211 3 27 suv
#> 212 4 27 suv
#> 213 5 27 suv
#> 214 6 27 suv
#> 215 7 27 suv
#> 216 8 27 suv
#> 217 1 28 suv
#> 218 2 28 suv
#> 219 3 28 suv
#> 220 4 28 suv
#> 221 5 28 suv
#> 222 6 28 suv
#> 223 7 28 suv
#> 224 8 28 suv
#> 225 1 29 suv
#> 226 2 29 suv
#> 227 3 29 suv
#> 228 4 29 suv
#> 229 5 29 suv
#> 230 6 29 suv
#> 231 7 29 suv
#> 232 8 29 suv
#> 233 1 30 suv
#> 234 2 30 suv
waffle_iron(mpg, aes_d(group = class), sample_size = 0.75)
#> y x group
#> 1 1 1 2seater
#> 2 2 1 2seater
#> 3 3 1 2seater
#> 4 4 1 2seater
#> 5 5 1 compact
#> 6 6 1 compact
#> 7 7 1 compact
#> 8 8 1 compact
#> 9 1 2 compact
#> 10 2 2 compact
#> 11 3 2 compact
#> 12 4 2 compact
#> 13 5 2 compact
#> 14 6 2 compact
#> 15 7 2 compact
#> 16 8 2 compact
#> 17 1 3 compact
#> 18 2 3 compact
#> 19 3 3 compact
#> 20 4 3 compact
#> 21 5 3 compact
#> 22 6 3 compact
#> 23 7 3 compact
#> 24 8 3 compact
#> 25 1 4 compact
#> 26 2 4 compact
#> 27 3 4 compact
#> 28 4 4 compact
#> 29 5 4 compact
#> 30 6 4 compact
#> 31 7 4 compact
#> 32 8 4 compact
#> 33 1 5 compact
#> 34 2 5 compact
#> 35 3 5 compact
#> 36 4 5 compact
#> 37 5 5 compact
#> 38 6 5 midsize
#> 39 7 5 midsize
#> 40 8 5 midsize
#> 41 1 6 midsize
#> 42 2 6 midsize
#> 43 3 6 midsize
#> 44 4 6 midsize
#> 45 5 6 midsize
#> 46 6 6 midsize
#> 47 7 6 midsize
#> 48 8 6 midsize
#> 49 1 7 midsize
#> 50 2 7 midsize
#> 51 3 7 midsize
#> 52 4 7 midsize
#> 53 5 7 midsize
#> 54 6 7 midsize
#> 55 7 7 midsize
#> 56 8 7 midsize
#> 57 1 8 midsize
#> 58 2 8 midsize
#> 59 3 8 midsize
#> 60 4 8 midsize
#> 61 5 8 midsize
#> 62 6 8 midsize
#> 63 7 8 midsize
#> 64 8 8 midsize
#> 65 1 9 midsize
#> 66 2 9 midsize
#> 67 3 9 midsize
#> 68 4 9 midsize
#> 69 5 9 midsize
#> 70 6 9 minivan
#> 71 7 9 minivan
#> 72 8 9 minivan
#> 73 1 10 minivan
#> 74 2 10 minivan
#> 75 3 10 minivan
#> 76 4 10 minivan
#> 77 5 10 minivan
#> 78 6 10 minivan
#> 79 7 10 pickup
#> 80 8 10 pickup
#> 81 1 11 pickup
#> 82 2 11 pickup
#> 83 3 11 pickup
#> 84 4 11 pickup
#> 85 5 11 pickup
#> 86 6 11 pickup
#> 87 7 11 pickup
#> 88 8 11 pickup
#> 89 1 12 pickup
#> 90 2 12 pickup
#> 91 3 12 pickup
#> 92 4 12 pickup
#> 93 5 12 pickup
#> 94 6 12 pickup
#> 95 7 12 pickup
#> 96 8 12 pickup
#> 97 1 13 pickup
#> 98 2 13 pickup
#> 99 3 13 pickup
#> 100 4 13 pickup
#> 101 5 13 pickup
#> 102 6 13 pickup
#> 103 7 13 subcompact
#> 104 8 13 subcompact
#> 105 1 14 subcompact
#> 106 2 14 subcompact
#> 107 3 14 subcompact
#> 108 4 14 subcompact
#> 109 5 14 subcompact
#> 110 6 14 subcompact
#> 111 7 14 subcompact
#> 112 8 14 subcompact
#> 113 1 15 subcompact
#> 114 2 15 subcompact
#> 115 3 15 subcompact
#> 116 4 15 subcompact
#> 117 5 15 subcompact
#> 118 6 15 subcompact
#> 119 7 15 subcompact
#> 120 8 15 subcompact
#> 121 1 16 subcompact
#> 122 2 16 subcompact
#> 123 3 16 subcompact
#> 124 4 16 subcompact
#> 125 5 16 subcompact
#> 126 6 16 subcompact
#> 127 7 16 subcompact
#> 128 8 16 subcompact
#> 129 1 17 suv
#> 130 2 17 suv
#> 131 3 17 suv
#> 132 4 17 suv
#> 133 5 17 suv
#> 134 6 17 suv
#> 135 7 17 suv
#> 136 8 17 suv
#> 137 1 18 suv
#> 138 2 18 suv
#> 139 3 18 suv
#> 140 4 18 suv
#> 141 5 18 suv
#> 142 6 18 suv
#> 143 7 18 suv
#> 144 8 18 suv
#> 145 1 19 suv
#> 146 2 19 suv
#> 147 3 19 suv
#> 148 4 19 suv
#> 149 5 19 suv
#> 150 6 19 suv
#> 151 7 19 suv
#> 152 8 19 suv
#> 153 1 20 suv
#> 154 2 20 suv
#> 155 3 20 suv
#> 156 4 20 suv
#> 157 5 20 suv
#> 158 6 20 suv
#> 159 7 20 suv
#> 160 8 20 suv
#> 161 1 21 suv
#> 162 2 21 suv
#> 163 3 21 suv
#> 164 4 21 suv
#> 165 5 21 suv
#> 166 6 21 suv
#> 167 7 21 suv
#> 168 8 21 suv
#> 169 1 22 suv
#> 170 2 22 suv
#> 171 3 22 suv
#> 172 4 22 suv
#> 173 5 22 suv
#> 174 6 22 suv
#> 175 7 22 suv