Debian Codegraph @

tests/testthat/_snaps/skim_print.md

raw symbols SCIP
1 # Skim prints a header for the entire output and each type
2
3 Code
4 input <- skim(iris)
5 input
6 Output
7 -- Data Summary ------------------------
8 Values
9 Name iris
10 Number of rows 150
11 Number of columns 5
12 _______________________
13 Column type frequency:
14 factor 1
15 numeric 4
16 ________________________
17 Group variables None
18
19 -- Variable type: factor -------------------------------------------------------
20 skim_variable n_missing complete_rate ordered n_unique
21 1 Species 0 1 FALSE 3
22 top_counts
23 1 set: 50, ver: 50, vir: 50
24
25 -- Variable type: numeric ------------------------------------------------------
26 skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
27 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
28 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
29 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
30 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃
31 Code
32 input$numeric.hist <- NULL
33 input
34 Output
35 -- Data Summary ------------------------
36 Values
37 Name iris
38 Number of rows 150
39 Number of columns 5
40 _______________________
41 Column type frequency:
42 factor 1
43 numeric 4
44 ________________________
45 Group variables None
46
47 -- Variable type: factor -------------------------------------------------------
48 skim_variable n_missing complete_rate ordered n_unique
49 1 Species 0 1 FALSE 3
50 top_counts
51 1 set: 50, ver: 50, vir: 50
52
53 -- Variable type: numeric ------------------------------------------------------
54 skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100
55 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9
56 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4
57 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9
58 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5
59
60 # Skim prints a special header for grouped data frames
61
62 Code
63 skim(dplyr::group_by(iris, Species))
64 Output
65 -- Data Summary ------------------------
66 Values
67 Name dplyr::group_by(iris, Spe...
68 Number of rows 150
69 Number of columns 5
70 _______________________
71 Column type frequency:
72 numeric 4
73 ________________________
74 Group variables Species
75
76 -- Variable type: numeric ------------------------------------------------------
77 skim_variable Species n_missing complete_rate mean sd p0 p25 p50
78 1 Sepal.Length setosa 0 1 5.01 0.352 4.3 4.8 5
79 2 Sepal.Length versicolor 0 1 5.94 0.516 4.9 5.6 5.9
80 3 Sepal.Length virginica 0 1 6.59 0.636 4.9 6.22 6.5
81 4 Sepal.Width setosa 0 1 3.43 0.379 2.3 3.2 3.4
82 5 Sepal.Width versicolor 0 1 2.77 0.314 2 2.52 2.8
83 6 Sepal.Width virginica 0 1 2.97 0.322 2.2 2.8 3
84 7 Petal.Length setosa 0 1 1.46 0.174 1 1.4 1.5
85 8 Petal.Length versicolor 0 1 4.26 0.470 3 4 4.35
86 9 Petal.Length virginica 0 1 5.55 0.552 4.5 5.1 5.55
87 10 Petal.Width setosa 0 1 0.246 0.105 0.1 0.2 0.2
88 11 Petal.Width versicolor 0 1 1.33 0.198 1 1.2 1.3
89 12 Petal.Width virginica 0 1 2.03 0.275 1.4 1.8 2
90 p75 p100 hist
91 1 5.2 5.8 ▃▃▇▅▁
92 2 6.3 7 ▂▇▆▃▃
93 3 6.9 7.9 ▁▃▇▃▂
94 4 3.68 4.4 ▁▃▇▅▂
95 5 3 3.4 ▁▅▆▇▂
96 6 3.18 3.8 ▂▆▇▅▁
97 7 1.58 1.9 ▁▃▇▃▁
98 8 4.6 5.1 ▂▂▇▇▆
99 9 5.88 6.9 ▃▇▇▃▂
100 10 0.3 0.6 ▇▂▂▁▁
101 11 1.5 1.8 ▅▇▃▆▁
102 12 2.3 2.5 ▂▇▆▅▇
103
104 # Skim lists print as expected
105
106 Code
107 partition(skimmed)
108 Output
109 $factor
110
111 -- Variable type: factor -------------------------------------------------------
112 skim_variable n_missing complete_rate ordered n_unique top_counts
113 1 Species 0 1 FALSE 3 set: 50, ver: 50, vir:~
114
115 $numeric
116
117 -- Variable type: numeric ------------------------------------------------------
118 skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
119 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
120 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
121 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
122 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃
123
124
125 # knit_print produces expected results
126
127 Code
128 cat(input)
129 Output
130
131 Table: Data summary
132
133 | | |
134 |:------------------------|:----|
135 |Name |iris |
136 |Number of rows |150 |
137 |Number of columns |5 |
138 |_______________________ | |
139 |Column type frequency: | |
140 |factor |1 |
141 |numeric |4 |
142 |________________________ | |
143 |Group variables |None |
144
145
146 **Variable type: factor**
147
148 |skim_variable | n_missing| complete_rate|ordered | n_unique|top_counts |
149 |:-------------|---------:|-------------:|:-------|--------:|:-------------------------|
150 |Species | 0| 1|FALSE | 3|set: 50, ver: 50, vir: 50 |
151
152
153 **Variable type: numeric**
154
155 |skim_variable | n_missing| complete_rate| mean| sd| p0| p25| p50| p75| p100|hist |
156 |:-------------|---------:|-------------:|----:|----:|---:|---:|----:|---:|----:|:-----|
157 |Sepal.Length | 0| 1| 5.84| 0.83| 4.3| 5.1| 5.80| 6.4| 7.9|▆▇▇▅▂ |
158 |Sepal.Width | 0| 1| 3.06| 0.44| 2.0| 2.8| 3.00| 3.3| 4.4|▁▆▇▂▁ |
159 |Petal.Length | 0| 1| 3.76| 1.77| 1.0| 1.6| 4.35| 5.1| 6.9|▇▁▆▇▂ |
160 |Petal.Width | 0| 1| 1.20| 0.76| 0.1| 0.3| 1.30| 1.8| 2.5|▇▁▇▅▃ |
161
162
163 # knit_print works with skim summaries
164
165 Code
166 cat(knitr::knit_print(summarized))
167 Output
168 Table: Data summary
169
170 | | |
171 |:------------------------|:----|
172 |Name |iris |
173 |Number of rows |150 |
174 |Number of columns |5 |
175 |_______________________ | |
176 |Column type frequency: | |
177 |factor |1 |
178 |numeric |4 |
179 |________________________ | |
180 |Group variables |None |
181
182 # knit_print appropriately falls back to tibble printing
183
184 Code
185 input <- knitr::knit_print(reduced)
186 Output
187 # A tibble: 5 x 2
188 skim_variable numeric.mean
189 <chr> <dbl>
190 1 Species NA
191 2 Sepal.Length 5.84
192 3 Sepal.Width 3.06
193 4 Petal.Length 3.76
194 5 Petal.Width 1.20
195
196 # Summaries can be suppressed within knitr
197
198 Code
199 cat(knitr::knit_print(skimmed, options = options))
200 Output
201
202
203
204 **Variable type: factor**
205
206 |skim_variable | n_missing| complete_rate|ordered | n_unique|top_counts |
207 |:-------------|---------:|-------------:|:-------|--------:|:-------------------------|
208 |Species | 0| 1|FALSE | 3|set: 50, ver: 50, vir: 50 |
209
210
211 **Variable type: numeric**
212
213 |skim_variable | n_missing| complete_rate| mean| sd| p0| p25| p50| p75| p100|hist |
214 |:-------------|---------:|-------------:|----:|----:|---:|---:|----:|---:|----:|:-----|
215 |Sepal.Length | 0| 1| 5.84| 0.83| 4.3| 5.1| 5.80| 6.4| 7.9|▆▇▇▅▂ |
216 |Sepal.Width | 0| 1| 3.06| 0.44| 2.0| 2.8| 3.00| 3.3| 4.4|▁▆▇▂▁ |
217 |Petal.Length | 0| 1| 3.76| 1.77| 1.0| 1.6| 4.35| 5.1| 6.9|▇▁▆▇▂ |
218 |Petal.Width | 0| 1| 1.20| 0.76| 0.1| 0.3| 1.30| 1.8| 2.5|▇▁▇▅▃ |
219
220
221 # Skim lists have a separate knit_print method
222
223 Code
224 cat(knit_print(skim_list))
225 Output
226
227
228
229 **Variable type: factor**
230
231 |skim_variable | n_missing| complete_rate|ordered | n_unique|top_counts |
232 |:-------------|---------:|-------------:|:-------|--------:|:-------------------------|
233 |Species | 0| 1|FALSE | 3|set: 50, ver: 50, vir: 50 |
234
235
236 **Variable type: numeric**
237
238 |skim_variable | n_missing| complete_rate| mean| sd| p0| p25| p50| p75| p100|hist |
239 |:-------------|---------:|-------------:|----:|----:|---:|---:|----:|---:|----:|:-----|
240 |Sepal.Length | 0| 1| 5.84| 0.83| 4.3| 5.1| 5.80| 6.4| 7.9|▆▇▇▅▂ |
241 |Sepal.Width | 0| 1| 3.06| 0.44| 2.0| 2.8| 3.00| 3.3| 4.4|▁▆▇▂▁ |
242 |Petal.Length | 0| 1| 3.76| 1.77| 1.0| 1.6| 4.35| 5.1| 6.9|▇▁▆▇▂ |
243 |Petal.Width | 0| 1| 1.20| 0.76| 0.1| 0.3| 1.30| 1.8| 2.5|▇▁▇▅▃ |
244
245
246 # You can yank a type from a skim_df and call knit_print
247
248 Code
249 cat(knit_print(skim_one))
250 Output
251
252
253 **Variable type: factor**
254
255 |skim_variable | n_missing| complete_rate|ordered | n_unique|top_counts |
256 |:-------------|---------:|-------------:|:-------|--------:|:-------------------------|
257 |Species | 0| 1|FALSE | 3|set: 50, ver: 50, vir: 50 |
258
259
260
261 # Skim falls back to tibble::print.tbl() appropriately
262
263 Code
264 input <- skim(iris)
265 dplyr::select(input, numeric.mean)
266 Output
267 # A tibble: 5 x 1
268 numeric.mean
269 <dbl>
270 1 NA
271 2 5.84
272 3 3.06
273 4 3.76
274 5 1.20
275
276 # Print focused objects appropriately
277
278 Code
279 focus(skimmed, n_missing)
280 Output
281 -- Data Summary ------------------------
282 Values
283 Name iris
284 Number of rows 150
285 Number of columns 5
286 _______________________
287 Column type frequency:
288 factor 1
289 numeric 4
290 ________________________
291 Group variables None
292
293 -- Variable type: factor -------------------------------------------------------
294 skim_variable n_missing
295 1 Species 0
296
297 -- Variable type: numeric ------------------------------------------------------
298 skim_variable n_missing
299 1 Sepal.Length 0
300 2 Sepal.Width 0
301 3 Petal.Length 0
302 4 Petal.Width 0
303
304 # Support for smaller consoles can be set with the width option
305
306 Code
307 skim(iris)
308 Output
309 -- Data Summary ------------------------
310 Values
311 Name iris
312 Number of rows 150
313 Number of columns 5
314 _______________________
315 Column type frequency:
316 factor 1
317 numeric 4
318 ________________________
319 Group variables None
320
321 -- Variable type: factor -------------------------------------------------------
322 skim_variable n_missing complete_rate ordered n_unique
323 1 Species 0 1 FALSE 3
324 top_counts
325 1 set: 50, ver: 50, vir: 50
326
327 -- Variable type: numeric ------------------------------------------------------
328 skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
329 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
330 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
331 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
332 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃
333
334 # Table header width can be controlled by an option
335
336 Code
337 skimmed
338 Output
339 -- Data Summary ------------------------
340 Values
341 Name iris
342 Number of rows 150
343 Number of columns 5
344 _______________________
345 Column type frequency:
346 factor 1
347 numeric 4
348 ________________________
349 Group variables None
350
351 -- Variable type: factor -------------------------------------------------------
352 skim_variable n_missing complete_rate ordered n_unique
353 1 Species 0 1 FALSE 3
354 top_counts
355 1 set: 50, ver: 50, vir: 50
356
357 -- Variable type: numeric ------------------------------------------------------
358 skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
359 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
360 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
361 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
362 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃
363
364 # skimr creates appropriate output for Jupyter
365
366 Code
367 skimmed
368 Output
369 -- Data Summary ------------------------
370 Values
371 Name iris
372 Number of rows 150
373 Number of columns 5
374 _______________________
375 Column type frequency:
376 factor 1
377 numeric 4
378 ________________________
379 Group variables None
380
381 -- Variable type: factor -------------------------------------------------------
382 skim_variable n_missing complete_rate ordered n_unique
383 1 Species 0 1 FALSE 3
384 top_counts
385 1 set: 50, ver: 50, vir: 50
386
387 -- Variable type: numeric ------------------------------------------------------
388 skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
389 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
390 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
391 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
392 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃
393