Debian Codegraph @

inst/doc/using_skimr.html

raw symbols SCIP
1 <!DOCTYPE html>
2
3 <html>
4
5 <head>
6
7 <meta charset="utf-8" />
8 <meta name="generator" content="pandoc" />
9 <meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
10
11 <meta name="viewport" content="width=device-width, initial-scale=1" />
12
13
14 <meta name="date" content="2026-01-09" />
15
16 <title>Using Skimr</title>
17
18 <script>// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
19 // be compatible with the behavior of Pandoc < 2.8).
20 document.addEventListener('DOMContentLoaded', function(e) {
21 var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
22 var i, h, a;
23 for (i = 0; i < hs.length; i++) {
24 h = hs[i];
25 if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
26 a = h.attributes;
27 while (a.length > 0) h.removeAttribute(a[0].name);
28 }
29 });
30 </script>
31
32 <style type="text/css">
33 code{white-space: pre-wrap;}
34 span.smallcaps{font-variant: small-caps;}
35 span.underline{text-decoration: underline;}
36 div.column{display: inline-block; vertical-align: top; width: 50%;}
37 div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
38 ul.task-list{list-style: none;}
39 </style>
40
41
42
43 <style type="text/css">
44 code {
45 white-space: pre;
46 }
47 .sourceCode {
48 overflow: visible;
49 }
50 </style>
51 <style type="text/css" data-origin="pandoc">
52 pre > code.sourceCode { white-space: pre; position: relative; }
53 pre > code.sourceCode > span { line-height: 1.25; }
54 pre > code.sourceCode > span:empty { height: 1.2em; }
55 .sourceCode { overflow: visible; }
56 code.sourceCode > span { color: inherit; text-decoration: inherit; }
57 div.sourceCode { margin: 1em 0; }
58 pre.sourceCode { margin: 0; }
59 @media screen {
60 div.sourceCode { overflow: auto; }
61 }
62 @media print {
63 pre > code.sourceCode { white-space: pre-wrap; }
64 pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
65 }
66 pre.numberSource code
67 { counter-reset: source-line 0; }
68 pre.numberSource code > span
69 { position: relative; left: -4em; counter-increment: source-line; }
70 pre.numberSource code > span > a:first-child::before
71 { content: counter(source-line);
72 position: relative; left: -1em; text-align: right; vertical-align: baseline;
73 border: none; display: inline-block;
74 -webkit-touch-callout: none; -webkit-user-select: none;
75 -khtml-user-select: none; -moz-user-select: none;
76 -ms-user-select: none; user-select: none;
77 padding: 0 4px; width: 4em;
78 color: #aaaaaa;
79 }
80 pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
81 div.sourceCode
82 { }
83 @media screen {
84 pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
85 }
86 code span.al { color: #ff0000; font-weight: bold; }
87 code span.an { color: #60a0b0; font-weight: bold; font-style: italic; }
88 code span.at { color: #7d9029; }
89 code span.bn { color: #40a070; }
90 code span.bu { color: #008000; }
91 code span.cf { color: #007020; font-weight: bold; }
92 code span.ch { color: #4070a0; }
93 code span.cn { color: #880000; }
94 code span.co { color: #60a0b0; font-style: italic; }
95 code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; }
96 code span.do { color: #ba2121; font-style: italic; }
97 code span.dt { color: #902000; }
98 code span.dv { color: #40a070; }
99 code span.er { color: #ff0000; font-weight: bold; }
100 code span.ex { }
101 code span.fl { color: #40a070; }
102 code span.fu { color: #06287e; }
103 code span.im { color: #008000; font-weight: bold; }
104 code span.in { color: #60a0b0; font-weight: bold; font-style: italic; }
105 code span.kw { color: #007020; font-weight: bold; }
106 code span.op { color: #666666; }
107 code span.ot { color: #007020; }
108 code span.pp { color: #bc7a00; }
109 code span.sc { color: #4070a0; }
110 code span.ss { color: #bb6688; }
111 code span.st { color: #4070a0; }
112 code span.va { color: #19177c; }
113 code span.vs { color: #4070a0; }
114 code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; }
115 </style>
116 <script>
117 // apply pandoc div.sourceCode style to pre.sourceCode instead
118 (function() {
119 var sheets = document.styleSheets;
120 for (var i = 0; i < sheets.length; i++) {
121 if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
122 try { var rules = sheets[i].cssRules; } catch (e) { continue; }
123 var j = 0;
124 while (j < rules.length) {
125 var rule = rules[j];
126 // check if there is a div.sourceCode rule
127 if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") {
128 j++;
129 continue;
130 }
131 var style = rule.style.cssText;
132 // check if color or background-color is set
133 if (rule.style.color === '' && rule.style.backgroundColor === '') {
134 j++;
135 continue;
136 }
137 // replace div.sourceCode by a pre.sourceCode rule
138 sheets[i].deleteRule(j);
139 sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
140 }
141 }
142 })();
143 </script>
144
145
146
147
148 <style type="text/css">body {
149 background-color: #fff;
150 margin: 1em auto;
151 max-width: 700px;
152 overflow: visible;
153 padding-left: 2em;
154 padding-right: 2em;
155 font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
156 font-size: 14px;
157 line-height: 1.35;
158 }
159 #TOC {
160 clear: both;
161 margin: 0 0 10px 10px;
162 padding: 4px;
163 width: 400px;
164 border: 1px solid #CCCCCC;
165 border-radius: 5px;
166 background-color: #f6f6f6;
167 font-size: 13px;
168 line-height: 1.3;
169 }
170 #TOC .toctitle {
171 font-weight: bold;
172 font-size: 15px;
173 margin-left: 5px;
174 }
175 #TOC ul {
176 padding-left: 40px;
177 margin-left: -1.5em;
178 margin-top: 5px;
179 margin-bottom: 5px;
180 }
181 #TOC ul ul {
182 margin-left: -2em;
183 }
184 #TOC li {
185 line-height: 16px;
186 }
187 table {
188 margin: 1em auto;
189 border-width: 1px;
190 border-color: #DDDDDD;
191 border-style: outset;
192 border-collapse: collapse;
193 }
194 table th {
195 border-width: 2px;
196 padding: 5px;
197 border-style: inset;
198 }
199 table td {
200 border-width: 1px;
201 border-style: inset;
202 line-height: 18px;
203 padding: 5px 5px;
204 }
205 table, table th, table td {
206 border-left-style: none;
207 border-right-style: none;
208 }
209 table thead, table tr.even {
210 background-color: #f7f7f7;
211 }
212 p {
213 margin: 0.5em 0;
214 }
215 blockquote {
216 background-color: #f6f6f6;
217 padding: 0.25em 0.75em;
218 }
219 hr {
220 border-style: solid;
221 border: none;
222 border-top: 1px solid #777;
223 margin: 28px 0;
224 }
225 dl {
226 margin-left: 0;
227 }
228 dl dd {
229 margin-bottom: 13px;
230 margin-left: 13px;
231 }
232 dl dt {
233 font-weight: bold;
234 }
235 ul {
236 margin-top: 0;
237 }
238 ul li {
239 list-style: circle outside;
240 }
241 ul ul {
242 margin-bottom: 0;
243 }
244 pre, code {
245 background-color: #f7f7f7;
246 border-radius: 3px;
247 color: #333;
248 white-space: pre-wrap;
249 }
250 pre {
251 border-radius: 3px;
252 margin: 5px 0px 10px 0px;
253 padding: 10px;
254 }
255 pre:not([class]) {
256 background-color: #f7f7f7;
257 }
258 code {
259 font-family: Consolas, Monaco, 'Courier New', monospace;
260 font-size: 85%;
261 }
262 p > code, li > code {
263 padding: 2px 0px;
264 }
265 div.figure {
266 text-align: center;
267 }
268 img {
269 background-color: #FFFFFF;
270 padding: 2px;
271 border: 1px solid #DDDDDD;
272 border-radius: 3px;
273 border: 1px solid #CCCCCC;
274 margin: 0 5px;
275 }
276 h1 {
277 margin-top: 0;
278 font-size: 35px;
279 line-height: 40px;
280 }
281 h2 {
282 border-bottom: 4px solid #f7f7f7;
283 padding-top: 10px;
284 padding-bottom: 2px;
285 font-size: 145%;
286 }
287 h3 {
288 border-bottom: 2px solid #f7f7f7;
289 padding-top: 10px;
290 font-size: 120%;
291 }
292 h4 {
293 border-bottom: 1px solid #f7f7f7;
294 margin-left: 8px;
295 font-size: 105%;
296 }
297 h5, h6 {
298 border-bottom: 1px solid #ccc;
299 font-size: 105%;
300 }
301 a {
302 color: #0033dd;
303 text-decoration: none;
304 }
305 a:hover {
306 color: #6666ff; }
307 a:visited {
308 color: #800080; }
309 a:visited:hover {
310 color: #BB00BB; }
311 a[href^="http:"] {
312 text-decoration: underline; }
313 a[href^="https:"] {
314 text-decoration: underline; }
315
316 code > span.kw { color: #555; font-weight: bold; }
317 code > span.dt { color: #902000; }
318 code > span.dv { color: #40a070; }
319 code > span.bn { color: #d14; }
320 code > span.fl { color: #d14; }
321 code > span.ch { color: #d14; }
322 code > span.st { color: #d14; }
323 code > span.co { color: #888888; font-style: italic; }
324 code > span.ot { color: #007020; }
325 code > span.al { color: #ff0000; font-weight: bold; }
326 code > span.fu { color: #900; font-weight: bold; }
327 code > span.er { color: #a61717; background-color: #e3d2d2; }
328 </style>
329
330
331
332
333 </head>
334
335 <body>
336
337
338
339
340 <h1 class="title toc-ignore">Using Skimr</h1>
341 <h4 class="date">2026-01-09</h4>
342
343
344
345 <div id="introduction" class="section level2">
346 <h2>Introduction</h2>
347 <p><code>skimr</code> is designed to provide summary statistics about
348 variables in data frames, tibbles, data tables and vectors. It is
349 opinionated in its defaults, but easy to modify.</p>
350 <p>In base R, the most similar functions are <code>summary()</code> for
351 vectors and data frames and <code>fivenum()</code> for numeric
352 vectors:</p>
353 <div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">summary</span>(iris)</span></code></pre></div>
354 <pre><code>## Sepal.Length Sepal.Width Petal.Length Petal.Width
355 ## Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
356 ## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
357 ## Median :5.800 Median :3.000 Median :4.350 Median :1.300
358 ## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
359 ## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
360 ## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
361 ## Species
362 ## setosa :50
363 ## versicolor:50
364 ## virginica :50
365 ##
366 ##
367 ## </code></pre>
368 <div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a><span class="fu">summary</span>(iris<span class="sc">$</span>Sepal.Length)</span></code></pre></div>
369 <pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
370 ## 4.300 5.100 5.800 5.843 6.400 7.900</code></pre>
371 <div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a><span class="fu">fivenum</span>(iris<span class="sc">$</span>Sepal.Length)</span></code></pre></div>
372 <pre><code>## [1] 4.3 5.1 5.8 6.4 7.9</code></pre>
373 <div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" tabindex="-1"></a><span class="fu">summary</span>(iris<span class="sc">$</span>Species)</span></code></pre></div>
374 <pre><code>## setosa versicolor virginica
375 ## 50 50 50</code></pre>
376 </div>
377 <div id="the-skim-function" class="section level2">
378 <h2>The <code>skim()</code> function</h2>
379 <p>The core function of <code>skimr</code> is <code>skim()</code>, which
380 is designed to work with (grouped) data frames, and will try coerce
381 other objects to data frames if possible. Like <code>summary()</code>,
382 <code>skim()</code>’s method for data frames presents results for every
383 column; the statistics it provides depend on the class of the
384 variable.</p>
385 <div id="skimming-data-frames" class="section level3">
386 <h3>Skimming data frames</h3>
387 <p>By design, the main focus of <code>skimr</code> is on data frames; it
388 is intended to fit well within a data <a href="https://r4ds.had.co.nz/pipes.html">pipeline</a> and relies
389 extensively on <a href="https://tidyverse.org/">tidyverse</a>
390 vocabulary, which focuses on data frames.</p>
391 <p>Results of <code>skim()</code> are <em>printed</em> horizontally,
392 with one section per variable type and one row per variable.</p>
393 <div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" tabindex="-1"></a><span class="fu">library</span>(skimr)</span>
394 <span id="cb9-2"><a href="#cb9-2" tabindex="-1"></a><span class="fu">skim</span>(iris)</span></code></pre></div>
395 <pre><code>## ── Data Summary ────────────────────────
396 ## Values
397 ## Name iris
398 ## Number of rows 150
399 ## Number of columns 5
400 ## _______________________
401 ## Column type frequency:
402 ## factor 1
403 ## numeric 4
404 ## ________________________
405 ## Group variables None
406 ##
407 ## ── Variable type: factor ───────────────────────────────────────────────────────
408 ## skim_variable n_missing complete_rate ordered n_unique
409 ## 1 Species 0 1 FALSE 3
410 ## top_counts
411 ## 1 set: 50, ver: 50, vir: 50
412 ##
413 ## ── Variable type: numeric ──────────────────────────────────────────────────────
414 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
415 ## 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
416 ## 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
417 ## 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
418 ## 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃</code></pre>
419 <p>The format of the results are a single wide data frame combining the
420 results, with some additional attributes and two metadata columns:</p>
421 <ul>
422 <li><code>skim_variable</code>: name of the original variable</li>
423 <li><code>skim_type</code>: class of the variable</li>
424 </ul>
425 <p>Unlike many other objects within <code>R</code>, these columns are
426 intrinsic to the <code>skim_df</code> class. Dropping these variables
427 will result in a coercion to a <code>tibble</code>. The
428 <code>is_skim_df()</code> function is used to assert that an object is a
429 skim_df.</p>
430 <div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" tabindex="-1"></a><span class="fu">skim</span>(iris) <span class="sc">|&gt;</span> <span class="fu">is_skim_df</span>()</span></code></pre></div>
431 <pre><code>## [1] TRUE
432 ## attr(,&quot;message&quot;)
433 ## character(0)</code></pre>
434 <div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" tabindex="-1"></a><span class="fu">skim</span>(iris) <span class="sc">|&gt;</span></span>
435 <span id="cb13-2"><a href="#cb13-2" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">select</span>(<span class="sc">-</span>skim_type, <span class="sc">-</span>skim_variable) <span class="sc">|&gt;</span></span>
436 <span id="cb13-3"><a href="#cb13-3" tabindex="-1"></a> <span class="fu">is_skim_df</span>()</span></code></pre></div>
437 <pre><code>## [1] FALSE
438 ## attr(,&quot;message&quot;)
439 ## [1] &quot;Object is not a `skim_df`: missing column `skim_type`; missing column `skim_variable`&quot;</code></pre>
440 <div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" tabindex="-1"></a><span class="fu">skim</span>(iris) <span class="sc">|&gt;</span></span>
441 <span id="cb15-2"><a href="#cb15-2" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">select</span>(<span class="sc">-</span>n_missing) <span class="sc">|&gt;</span></span>
442 <span id="cb15-3"><a href="#cb15-3" tabindex="-1"></a> <span class="fu">is_skim_df</span>()</span></code></pre></div>
443 <pre><code>## [1] TRUE
444 ## attr(,&quot;message&quot;)
445 ## character(0)</code></pre>
446 <p>In order to avoid type coercion, columns for summary statistics for
447 different types are prefixed with the corresponding
448 <code>skim_type</code>. This means that the columns of the
449 <code>skim_df</code> are somewhat sparse, with quite a few missing
450 values. This is because for some statistics the representations for
451 different types of variables is different. For example, the mean of a
452 Date variable and of a numeric variable are represented differently when
453 printing, but this cannot be supported in a single vector. The exception
454 to this are <code>n_missing</code> and <code>complete_rate</code>
455 (missing/number of observations) which are the same for all types of
456 variables.</p>
457 <div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" tabindex="-1"></a><span class="fu">skim</span>(iris) <span class="sc">|&gt;</span></span>
458 <span id="cb17-2"><a href="#cb17-2" tabindex="-1"></a> tibble<span class="sc">::</span><span class="fu">as_tibble</span>()</span></code></pre></div>
459 <pre><code>## # A tibble: 5 × 15
460 ## skim_type skim_variable n_missing complete_rate factor.ordered factor.n_unique
461 ## &lt;chr&gt; &lt;chr&gt; &lt;int&gt; &lt;dbl&gt; &lt;lgl&gt; &lt;int&gt;
462 ## 1 factor Species 0 1 FALSE 3
463 ## 2 numeric Sepal.Length 0 1 NA NA
464 ## 3 numeric Sepal.Width 0 1 NA NA
465 ## 4 numeric Petal.Length 0 1 NA NA
466 ## 5 numeric Petal.Width 0 1 NA NA
467 ## # ℹ 9 more variables: factor.top_counts &lt;chr&gt;, numeric.mean &lt;dbl&gt;,
468 ## # numeric.sd &lt;dbl&gt;, numeric.p0 &lt;dbl&gt;, numeric.p25 &lt;dbl&gt;, numeric.p50 &lt;dbl&gt;,
469 ## # numeric.p75 &lt;dbl&gt;, numeric.p100 &lt;dbl&gt;, numeric.hist &lt;chr&gt;</code></pre>
470 <p>This is in contrast to <code>summary.data.frame()</code>, which
471 stores statistics in a <code>table</code>. The distinction is important,
472 because the <code>skim_df</code> object is pipeable and easy to use for
473 additional manipulation: for example, the user could select all of the
474 variable means, or all summary statistics for a specific variable.</p>
475 <div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" tabindex="-1"></a><span class="fu">skim</span>(iris) <span class="sc">|&gt;</span></span>
476 <span id="cb19-2"><a href="#cb19-2" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">filter</span>(skim_variable <span class="sc">==</span> <span class="st">&quot;Petal.Length&quot;</span>)</span></code></pre></div>
477 <pre><code>## ── Data Summary ────────────────────────
478 ## Values
479 ## Name iris
480 ## Number of rows 150
481 ## Number of columns 5
482 ## _______________________
483 ## Column type frequency:
484 ## numeric 1
485 ## ________________________
486 ## Group variables None
487 ##
488 ## ── Variable type: numeric ──────────────────────────────────────────────────────
489 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
490 ## 1 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂</code></pre>
491 <p>Most <code>dplyr</code> verbs should work as expected.</p>
492 <div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" tabindex="-1"></a><span class="fu">skim</span>(iris) <span class="sc">|&gt;</span></span>
493 <span id="cb21-2"><a href="#cb21-2" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">select</span>(skim_type, skim_variable, n_missing)</span></code></pre></div>
494 <pre><code>## ── Data Summary ────────────────────────
495 ## Values
496 ## Name iris
497 ## Number of rows 150
498 ## Number of columns 5
499 ## _______________________
500 ## Column type frequency:
501 ## factor 1
502 ## numeric 4
503 ## ________________________
504 ## Group variables None
505 ##
506 ## ── Variable type: factor ───────────────────────────────────────────────────────
507 ## skim_variable n_missing
508 ## 1 Species 0
509 ##
510 ## ── Variable type: numeric ──────────────────────────────────────────────────────
511 ## skim_variable n_missing
512 ## 1 Sepal.Length 0
513 ## 2 Sepal.Width 0
514 ## 3 Petal.Length 0
515 ## 4 Petal.Width 0</code></pre>
516 <p>The base skimmers <code>n_missing</code> and
517 <code>complete_rate</code> are computed for all of the columns in the
518 data. But all other type-based skimmers have a namespace. You need to
519 use a <code>skim_type</code> prefix to refer to correct column.</p>
520 <div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" tabindex="-1"></a><span class="fu">skim</span>(iris) <span class="sc">|&gt;</span></span>
521 <span id="cb23-2"><a href="#cb23-2" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">select</span>(skim_type, skim_variable, numeric.mean)</span></code></pre></div>
522 <pre><code>## ── Data Summary ────────────────────────
523 ## Values
524 ## Name iris
525 ## Number of rows 150
526 ## Number of columns 5
527 ## _______________________
528 ## Column type frequency:
529 ## factor 1
530 ## numeric 4
531 ## ________________________
532 ## Group variables None
533 ##
534 ## ── Variable type: numeric ──────────────────────────────────────────────────────
535 ## skim_variable mean
536 ## 1 Sepal.Length 5.84
537 ## 2 Sepal.Width 3.06
538 ## 3 Petal.Length 3.76
539 ## 4 Petal.Width 1.20</code></pre>
540 <p><code>skim()</code> also supports grouped data created by
541 <code>dplyr::group_by()</code>. In this case, one additional column for
542 each grouping variable is added to the <code>skim_df</code> object.</p>
543 <div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb25-1"><a href="#cb25-1" tabindex="-1"></a>iris <span class="sc">|&gt;</span></span>
544 <span id="cb25-2"><a href="#cb25-2" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">group_by</span>(Species) <span class="sc">|&gt;</span></span>
545 <span id="cb25-3"><a href="#cb25-3" tabindex="-1"></a> <span class="fu">skim</span>()</span></code></pre></div>
546 <pre><code>## ── Data Summary ────────────────────────
547 ## Values
548 ## Name dplyr::group_by(iris, Spe...
549 ## Number of rows 150
550 ## Number of columns 5
551 ## _______________________
552 ## Column type frequency:
553 ## numeric 4
554 ## ________________________
555 ## Group variables Species
556 ##
557 ## ── Variable type: numeric ──────────────────────────────────────────────────────
558 ## skim_variable Species n_missing complete_rate mean sd p0 p25 p50
559 ## 1 Sepal.Length setosa 0 1 5.01 0.352 4.3 4.8 5
560 ## 2 Sepal.Length versicolor 0 1 5.94 0.516 4.9 5.6 5.9
561 ## 3 Sepal.Length virginica 0 1 6.59 0.636 4.9 6.22 6.5
562 ## 4 Sepal.Width setosa 0 1 3.43 0.379 2.3 3.2 3.4
563 ## 5 Sepal.Width versicolor 0 1 2.77 0.314 2 2.52 2.8
564 ## 6 Sepal.Width virginica 0 1 2.97 0.322 2.2 2.8 3
565 ## 7 Petal.Length setosa 0 1 1.46 0.174 1 1.4 1.5
566 ## 8 Petal.Length versicolor 0 1 4.26 0.470 3 4 4.35
567 ## 9 Petal.Length virginica 0 1 5.55 0.552 4.5 5.1 5.55
568 ## 10 Petal.Width setosa 0 1 0.246 0.105 0.1 0.2 0.2
569 ## 11 Petal.Width versicolor 0 1 1.33 0.198 1 1.2 1.3
570 ## 12 Petal.Width virginica 0 1 2.03 0.275 1.4 1.8 2
571 ## p75 p100 hist
572 ## 1 5.2 5.8 ▃▂▇▃▁
573 ## 2 6.3 7 ▂▇▆▃▃
574 ## 3 6.9 7.9 ▁▃▇▃▂
575 ## 4 3.68 4.4 ▁▃▇▅▂
576 ## 5 3 3.4 ▁▅▆▇▂
577 ## 6 3.18 3.8 ▂▆▇▅▁
578 ## 7 1.58 1.9 ▁▃▇▃▁
579 ## 8 4.6 5.1 ▂▂▇▇▆
580 ## 9 5.88 6.9 ▃▇▇▃▂
581 ## 10 0.3 0.6 ▇▂▂▁▁
582 ## 11 1.5 1.8 ▅▇▃▆▁
583 ## 12 2.3 2.5 ▂▇▆▅▇</code></pre>
584 <p>Individual columns from a data frame may be selected using
585 tidyverse-style selectors.</p>
586 <div class="sourceCode" id="cb27"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" tabindex="-1"></a><span class="fu">skim</span>(iris, Sepal.Length, Species)</span></code></pre></div>
587 <pre><code>## ── Data Summary ────────────────────────
588 ## Values
589 ## Name iris
590 ## Number of rows 150
591 ## Number of columns 5
592 ## _______________________
593 ## Column type frequency:
594 ## factor 1
595 ## numeric 1
596 ## ________________________
597 ## Group variables None
598 ##
599 ## ── Variable type: factor ───────────────────────────────────────────────────────
600 ## skim_variable n_missing complete_rate ordered n_unique
601 ## 1 Species 0 1 FALSE 3
602 ## top_counts
603 ## 1 set: 50, ver: 50, vir: 50
604 ##
605 ## ── Variable type: numeric ──────────────────────────────────────────────────────
606 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
607 ## 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂</code></pre>
608 <p>Or with common <code>select</code> helpers.</p>
609 <div class="sourceCode" id="cb29"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" tabindex="-1"></a><span class="fu">skim</span>(iris, <span class="fu">starts_with</span>(<span class="st">&quot;Sepal&quot;</span>))</span></code></pre></div>
610 <pre><code>## ── Data Summary ────────────────────────
611 ## Values
612 ## Name iris
613 ## Number of rows 150
614 ## Number of columns 5
615 ## _______________________
616 ## Column type frequency:
617 ## numeric 2
618 ## ________________________
619 ## Group variables None
620 ##
621 ## ── Variable type: numeric ──────────────────────────────────────────────────────
622 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
623 ## 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
624 ## 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁</code></pre>
625 <p>If an individual column is of an unsupported class, it is treated as
626 a character variable with a warning.</p>
627 </div>
628 </div>
629 <div id="skimming-vectors" class="section level2">
630 <h2>Skimming vectors</h2>
631 <p>In <code>skimr</code> v2, <code>skim()</code> will attempt to coerce
632 non-data frames (such as vectors and matrices) to data frames. In most
633 cases with vectors, the object being evaluated should be equivalent to
634 wrapping the object in <code>as.data.frame()</code>.</p>
635 <p>For example, the <code>lynx</code> data set is class
636 <code>ts</code>.</p>
637 <div class="sourceCode" id="cb31"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb31-1"><a href="#cb31-1" tabindex="-1"></a><span class="fu">skim</span>(lynx)</span></code></pre></div>
638 <pre><code>## ── Data Summary ────────────────────────
639 ## Values
640 ## Name lynx
641 ## Number of rows 114
642 ## Number of columns 1
643 ## _______________________
644 ## Column type frequency:
645 ## ts 1
646 ## ________________________
647 ## Group variables None
648 ##
649 ## ── Variable type: ts ───────────────────────────────────────────────────────────
650 ## skim_variable n_missing complete_rate start end frequency deltat mean sd
651 ## 1 x 0 1 1821 1934 1 1 1538. 1586.
652 ## min max median line_graph
653 ## 1 39 6991 771 ⡈⢄⡠⢁⣀⠒⣀⠔</code></pre>
654 <p>Which is the same as coercing to a data frame.</p>
655 <div class="sourceCode" id="cb33"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb33-1"><a href="#cb33-1" tabindex="-1"></a><span class="fu">all.equal</span>(<span class="fu">skim</span>(lynx), <span class="fu">skim</span>(<span class="fu">as.data.frame</span>(lynx)))</span></code></pre></div>
656 <pre><code>## [1] &quot;Attributes: &lt; Component \&quot;df_name\&quot;: 1 string mismatch &gt;&quot;</code></pre>
657 </div>
658 <div id="skimming-matrices" class="section level2">
659 <h2>Skimming matrices</h2>
660 <p><code>skimr</code> does not support skimming matrices directly but
661 coerces them to data frames. Columns in the matrix become variables.
662 This behavior is similar to <code>summary.matrix()</code>). Three
663 possible ways to handle matrices with <code>skim()</code> parallel the
664 three variations of the mean function for matrices.</p>
665 <div class="sourceCode" id="cb35"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb35-1"><a href="#cb35-1" tabindex="-1"></a>m <span class="ot">&lt;-</span> <span class="fu">matrix</span>(<span class="fu">c</span>(<span class="dv">1</span>, <span class="dv">2</span>, <span class="dv">3</span>, <span class="dv">4</span>, <span class="dv">5</span>, <span class="dv">6</span>, <span class="dv">7</span>, <span class="dv">8</span>, <span class="dv">9</span>, <span class="dv">10</span>, <span class="dv">11</span>, <span class="dv">12</span>), <span class="at">nrow =</span> <span class="dv">4</span>, <span class="at">ncol =</span> <span class="dv">3</span>)</span>
666 <span id="cb35-2"><a href="#cb35-2" tabindex="-1"></a>m</span></code></pre></div>
667 <pre><code>## [,1] [,2] [,3]
668 ## [1,] 1 5 9
669 ## [2,] 2 6 10
670 ## [3,] 3 7 11
671 ## [4,] 4 8 12</code></pre>
672 <p>Skimming the matrix produces similar results to
673 <code>colMeans()</code>.</p>
674 <div class="sourceCode" id="cb37"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb37-1"><a href="#cb37-1" tabindex="-1"></a><span class="fu">colMeans</span>(m)</span></code></pre></div>
675 <pre><code>## [1] 2.5 6.5 10.5</code></pre>
676 <div class="sourceCode" id="cb39"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb39-1"><a href="#cb39-1" tabindex="-1"></a><span class="fu">skim</span>(m) <span class="co"># Similar to summary.matrix and colMeans()</span></span></code></pre></div>
677 <pre><code>## ── Data Summary ────────────────────────
678 ## Values
679 ## Name m
680 ## Number of rows 4
681 ## Number of columns 3
682 ## _______________________
683 ## Column type frequency:
684 ## numeric 3
685 ## ________________________
686 ## Group variables None
687 ##
688 ## ── Variable type: numeric ──────────────────────────────────────────────────────
689 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
690 ## 1 V1 0 1 2.5 1.29 1 1.75 2.5 3.25 4 ▇▇▁▇▇
691 ## 2 V2 0 1 6.5 1.29 5 5.75 6.5 7.25 8 ▇▇▁▇▇
692 ## 3 V3 0 1 10.5 1.29 9 9.75 10.5 11.2 12 ▇▇▁▇▇</code></pre>
693 <p>Skimming the transpose of the matrix will give row-wise results.</p>
694 <div class="sourceCode" id="cb41"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb41-1"><a href="#cb41-1" tabindex="-1"></a><span class="fu">rowMeans</span>(m)</span></code></pre></div>
695 <pre><code>## [1] 5 6 7 8</code></pre>
696 <div class="sourceCode" id="cb43"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb43-1"><a href="#cb43-1" tabindex="-1"></a><span class="fu">skim</span>(<span class="fu">t</span>(m))</span></code></pre></div>
697 <pre><code>## ── Data Summary ────────────────────────
698 ## Values
699 ## Name t(m)
700 ## Number of rows 3
701 ## Number of columns 4
702 ## _______________________
703 ## Column type frequency:
704 ## numeric 4
705 ## ________________________
706 ## Group variables None
707 ##
708 ## ── Variable type: numeric ──────────────────────────────────────────────────────
709 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
710 ## 1 V1 0 1 5 4 1 3 5 7 9 ▇▁▇▁▇
711 ## 2 V2 0 1 6 4 2 4 6 8 10 ▇▁▇▁▇
712 ## 3 V3 0 1 7 4 3 5 7 9 11 ▇▁▇▁▇
713 ## 4 V4 0 1 8 4 4 6 8 10 12 ▇▁▇▁▇</code></pre>
714 <p>And call <code>c()</code> on the matrix to get results across all
715 columns.</p>
716 <div class="sourceCode" id="cb45"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb45-1"><a href="#cb45-1" tabindex="-1"></a><span class="fu">skim</span>(<span class="fu">c</span>(m))</span></code></pre></div>
717 <pre><code>## ── Data Summary ────────────────────────
718 ## Values
719 ## Name c(m)
720 ## Number of rows 12
721 ## Number of columns 1
722 ## _______________________
723 ## Column type frequency:
724 ## numeric 1
725 ## ________________________
726 ## Group variables None
727 ##
728 ## ── Variable type: numeric ──────────────────────────────────────────────────────
729 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
730 ## 1 data 0 1 6.5 3.61 1 3.75 6.5 9.25 12 ▇▅▅▅▇</code></pre>
731 <div class="sourceCode" id="cb47"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb47-1"><a href="#cb47-1" tabindex="-1"></a><span class="fu">mean</span>(m)</span></code></pre></div>
732 <pre><code>## [1] 6.5</code></pre>
733 <div id="skimming-without-modification" class="section level3">
734 <h3>Skimming without modification</h3>
735 <p><code>skim_tee()</code> produces the same printed version as
736 <code>skim()</code> but returns the original, unmodified data frame.
737 This allows for continued piping of the original data.</p>
738 <div class="sourceCode" id="cb49"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb49-1"><a href="#cb49-1" tabindex="-1"></a>iris_setosa <span class="ot">&lt;-</span> iris <span class="sc">|&gt;</span></span>
739 <span id="cb49-2"><a href="#cb49-2" tabindex="-1"></a> <span class="fu">skim_tee</span>() <span class="sc">|&gt;</span></span>
740 <span id="cb49-3"><a href="#cb49-3" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">filter</span>(Species <span class="sc">==</span> <span class="st">&quot;setosa&quot;</span>)</span></code></pre></div>
741 <pre><code>## ── Data Summary ────────────────────────
742 ## Values
743 ## Name data
744 ## Number of rows 150
745 ## Number of columns 5
746 ## _______________________
747 ## Column type frequency:
748 ## factor 1
749 ## numeric 4
750 ## ________________________
751 ## Group variables None
752 ##
753 ## ── Variable type: factor ───────────────────────────────────────────────────────
754 ## skim_variable n_missing complete_rate ordered n_unique
755 ## 1 Species 0 1 FALSE 3
756 ## top_counts
757 ## 1 set: 50, ver: 50, vir: 50
758 ##
759 ## ── Variable type: numeric ──────────────────────────────────────────────────────
760 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
761 ## 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
762 ## 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
763 ## 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
764 ## 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃</code></pre>
765 <div class="sourceCode" id="cb51"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb51-1"><a href="#cb51-1" tabindex="-1"></a><span class="fu">head</span>(iris_setosa)</span></code></pre></div>
766 <pre><code>## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
767 ## 1 5.1 3.5 1.4 0.2 setosa
768 ## 2 4.9 3.0 1.4 0.2 setosa
769 ## 3 4.7 3.2 1.3 0.2 setosa
770 ## 4 4.6 3.1 1.5 0.2 setosa
771 ## 5 5.0 3.6 1.4 0.2 setosa
772 ## 6 5.4 3.9 1.7 0.4 setosa</code></pre>
773 <p>Note, that <code>skim_tee()</code> is customized differently than
774 <code>skim</code> itself. See below for more details.</p>
775 </div>
776 </div>
777 <div id="reshaping-the-results-from-skim" class="section level2">
778 <h2>Reshaping the results from <code>skim()</code></h2>
779 <p>As noted above, <code>skim()</code> returns a wide data frame. This
780 is usually the most sensible format for the majority of operations when
781 investigating data, but the package has some other functions to help
782 with edge cases.</p>
783 <p>First, <code>partition()</code> returns a named list of the wide data
784 frames for each data type. Unlike the original data the partitioned data
785 only has columns corresponding to the skimming functions used for this
786 data type. These data frames are, therefore, not <code>skim_df</code>
787 objects.</p>
788 <div class="sourceCode" id="cb53"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb53-1"><a href="#cb53-1" tabindex="-1"></a>iris <span class="sc">|&gt;</span></span>
789 <span id="cb53-2"><a href="#cb53-2" tabindex="-1"></a> <span class="fu">skim</span>() <span class="sc">|&gt;</span></span>
790 <span id="cb53-3"><a href="#cb53-3" tabindex="-1"></a> <span class="fu">partition</span>()</span></code></pre></div>
791 <pre><code>## $factor
792 ##
793 ## ── Variable type: factor ───────────────────────────────────────────────────────
794 ## skim_variable n_missing complete_rate ordered n_unique top_counts
795 ## 1 Species 0 1 FALSE 3 set: 50, ver: 50, vir:…
796 ##
797 ## $numeric
798 ##
799 ## ── Variable type: numeric ──────────────────────────────────────────────────────
800 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
801 ## 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
802 ## 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
803 ## 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
804 ## 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃</code></pre>
805 <p>Alternatively, <code>yank()</code> selects only the subtable for a
806 specific type. Think of it like <code>dplyr::select</code> on column
807 types in the original data. Again, unsuitable columns are dropped.</p>
808 <div class="sourceCode" id="cb55"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb55-1"><a href="#cb55-1" tabindex="-1"></a>iris <span class="sc">|&gt;</span></span>
809 <span id="cb55-2"><a href="#cb55-2" tabindex="-1"></a> <span class="fu">skim</span>() <span class="sc">|&gt;</span></span>
810 <span id="cb55-3"><a href="#cb55-3" tabindex="-1"></a> <span class="fu">yank</span>(<span class="st">&quot;numeric&quot;</span>)</span></code></pre></div>
811 <pre><code>##
812 ## ── Variable type: numeric ──────────────────────────────────────────────────────
813 ## skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
814 ## 1 Sepal.Length 0 1 5.84 0.828 4.3 5.1 5.8 6.4 7.9 ▆▇▇▅▂
815 ## 2 Sepal.Width 0 1 3.06 0.436 2 2.8 3 3.3 4.4 ▁▆▇▂▁
816 ## 3 Petal.Length 0 1 3.76 1.77 1 1.6 4.35 5.1 6.9 ▇▁▆▇▂
817 ## 4 Petal.Width 0 1 1.20 0.762 0.1 0.3 1.3 1.8 2.5 ▇▁▇▅▃</code></pre>
818 <p><code>to_long()</code> returns a single long data frame with columns
819 <code>variable</code>, <code>type</code>, <code>statistic</code> and
820 <code>formatted</code>. This is similar but not identical to the
821 <code>skim_df</code> object in <code>skimr</code> v1.</p>
822 <div class="sourceCode" id="cb57"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb57-1"><a href="#cb57-1" tabindex="-1"></a>iris <span class="sc">|&gt;</span></span>
823 <span id="cb57-2"><a href="#cb57-2" tabindex="-1"></a> <span class="fu">skim</span>() <span class="sc">|&gt;</span></span>
824 <span id="cb57-3"><a href="#cb57-3" tabindex="-1"></a> <span class="fu">to_long</span>() <span class="sc">|&gt;</span></span>
825 <span id="cb57-4"><a href="#cb57-4" tabindex="-1"></a> <span class="fu">head</span>()</span></code></pre></div>
826 <pre><code>## # A tibble: 6 × 4
827 ## skim_type skim_variable stat formatted
828 ## &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt;
829 ## 1 factor Species n_missing 0
830 ## 2 factor Species complete_rate 1
831 ## 3 factor Species factor.ordered FALSE
832 ## 4 factor Species factor.n_unique 3
833 ## 5 factor Species factor.top_counts set: 50, ver: 50, vir: 50
834 ## 6 numeric Sepal.Length n_missing 0</code></pre>
835 <p>Since the <code>skim_variable</code> and <code>skim_type</code>
836 columns are a core component of the <code>skim_df</code> class, it’s
837 possible to get unwanted side effects when using
838 <code>dplyr::select()</code>. Instead, use <code>focus()</code> to
839 select columns of the skimmed results and keep them as a
840 <code>skim_df</code>; it always keeps the metadata column.</p>
841 <div class="sourceCode" id="cb59"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb59-1"><a href="#cb59-1" tabindex="-1"></a>iris <span class="sc">|&gt;</span></span>
842 <span id="cb59-2"><a href="#cb59-2" tabindex="-1"></a> <span class="fu">skim</span>() <span class="sc">|&gt;</span></span>
843 <span id="cb59-3"><a href="#cb59-3" tabindex="-1"></a> <span class="fu">focus</span>(n_missing, numeric.mean)</span></code></pre></div>
844 <pre><code>## ── Data Summary ────────────────────────
845 ## Values
846 ## Name iris
847 ## Number of rows 150
848 ## Number of columns 5
849 ## _______________________
850 ## Column type frequency:
851 ## factor 1
852 ## numeric 4
853 ## ________________________
854 ## Group variables None
855 ##
856 ## ── Variable type: factor ───────────────────────────────────────────────────────
857 ## skim_variable n_missing
858 ## 1 Species 0
859 ##
860 ## ── Variable type: numeric ──────────────────────────────────────────────────────
861 ## skim_variable n_missing mean
862 ## 1 Sepal.Length 0 5.84
863 ## 2 Sepal.Width 0 3.06
864 ## 3 Petal.Length 0 3.76
865 ## 4 Petal.Width 0 1.20</code></pre>
866 </div>
867 <div id="rendering-the-results-of-skim" class="section level2">
868 <h2>Rendering the results of <code>skim()</code></h2>
869 <p>The <code>skim_df</code> object is a wide data frame. The display is
870 created by default using <code>print.skim_df()</code>; users can specify
871 additional options by explicitly calling
872 <code>print([skim_df object], ...)</code>.</p>
873 <p>For documents rendered by <code>knitr</code>, the package provides a
874 custom <code>knit_print</code> method. To use it, the final line of your
875 code chunk should have a <code>skim_df</code> object.</p>
876 <div class="sourceCode" id="cb61"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb61-1"><a href="#cb61-1" tabindex="-1"></a><span class="fu">skim</span>(Orange)</span></code></pre></div>
877 <table>
878 <caption>Data summary</caption>
879 <tbody>
880 <tr class="odd">
881 <td align="left">Name</td>
882 <td align="left">Orange</td>
883 </tr>
884 <tr class="even">
885 <td align="left">Number of rows</td>
886 <td align="left">35</td>
887 </tr>
888 <tr class="odd">
889 <td align="left">Number of columns</td>
890 <td align="left">3</td>
891 </tr>
892 <tr class="even">
893 <td align="left">_______________________</td>
894 <td align="left"></td>
895 </tr>
896 <tr class="odd">
897 <td align="left">Column type frequency:</td>
898 <td align="left"></td>
899 </tr>
900 <tr class="even">
901 <td align="left">factor</td>
902 <td align="left">1</td>
903 </tr>
904 <tr class="odd">
905 <td align="left">numeric</td>
906 <td align="left">2</td>
907 </tr>
908 <tr class="even">
909 <td align="left">________________________</td>
910 <td align="left"></td>
911 </tr>
912 <tr class="odd">
913 <td align="left">Group variables</td>
914 <td align="left">None</td>
915 </tr>
916 </tbody>
917 </table>
918 <p><strong>Variable type: factor</strong></p>
919 <table>
920 <colgroup>
921 <col width="17%" />
922 <col width="12%" />
923 <col width="17%" />
924 <col width="10%" />
925 <col width="11%" />
926 <col width="29%" />
927 </colgroup>
928 <thead>
929 <tr class="header">
930 <th align="left">skim_variable</th>
931 <th align="right">n_missing</th>
932 <th align="right">complete_rate</th>
933 <th align="left">ordered</th>
934 <th align="right">n_unique</th>
935 <th align="left">top_counts</th>
936 </tr>
937 </thead>
938 <tbody>
939 <tr class="odd">
940 <td align="left">Tree</td>
941 <td align="right">0</td>
942 <td align="right">1</td>
943 <td align="left">TRUE</td>
944 <td align="right">5</td>
945 <td align="left">3: 7, 1: 7, 5: 7, 2: 7</td>
946 </tr>
947 </tbody>
948 </table>
949 <p><strong>Variable type: numeric</strong></p>
950 <table style="width:100%;">
951 <colgroup>
952 <col width="16%" />
953 <col width="11%" />
954 <col width="16%" />
955 <col width="8%" />
956 <col width="8%" />
957 <col width="4%" />
958 <col width="7%" />
959 <col width="5%" />
960 <col width="8%" />
961 <col width="5%" />
962 <col width="7%" />
963 </colgroup>
964 <thead>
965 <tr class="header">
966 <th align="left">skim_variable</th>
967 <th align="right">n_missing</th>
968 <th align="right">complete_rate</th>
969 <th align="right">mean</th>
970 <th align="right">sd</th>
971 <th align="right">p0</th>
972 <th align="right">p25</th>
973 <th align="right">p50</th>
974 <th align="right">p75</th>
975 <th align="right">p100</th>
976 <th align="left">hist</th>
977 </tr>
978 </thead>
979 <tbody>
980 <tr class="odd">
981 <td align="left">age</td>
982 <td align="right">0</td>
983 <td align="right">1</td>
984 <td align="right">922.14</td>
985 <td align="right">491.86</td>
986 <td align="right">118</td>
987 <td align="right">484.0</td>
988 <td align="right">1004</td>
989 <td align="right">1372.0</td>
990 <td align="right">1582</td>
991 <td align="left">▃▇▁▇▇</td>
992 </tr>
993 <tr class="even">
994 <td align="left">circumference</td>
995 <td align="right">0</td>
996 <td align="right">1</td>
997 <td align="right">115.86</td>
998 <td align="right">57.49</td>
999 <td align="right">30</td>
1000 <td align="right">65.5</td>
1001 <td align="right">115</td>
1002 <td align="right">161.5</td>
1003 <td align="right">214</td>
1004 <td align="left">▇▃▇▇▅</td>
1005 </tr>
1006 </tbody>
1007 </table>
1008 <p>The same type of rendering is available from reshaped
1009 <code>skim_df</code> objects, those generated by
1010 <code>partition()</code> and <code>yank()</code> in particular.</p>
1011 <div class="sourceCode" id="cb62"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb62-1"><a href="#cb62-1" tabindex="-1"></a><span class="fu">skim</span>(Orange) <span class="sc">|&gt;</span></span>
1012 <span id="cb62-2"><a href="#cb62-2" tabindex="-1"></a> <span class="fu">yank</span>(<span class="st">&quot;numeric&quot;</span>)</span></code></pre></div>
1013 <p><strong>Variable type: numeric</strong></p>
1014 <table style="width:100%;">
1015 <colgroup>
1016 <col width="16%" />
1017 <col width="11%" />
1018 <col width="16%" />
1019 <col width="8%" />
1020 <col width="8%" />
1021 <col width="4%" />
1022 <col width="7%" />
1023 <col width="5%" />
1024 <col width="8%" />
1025 <col width="5%" />
1026 <col width="7%" />
1027 </colgroup>
1028 <thead>
1029 <tr class="header">
1030 <th align="left">skim_variable</th>
1031 <th align="right">n_missing</th>
1032 <th align="right">complete_rate</th>
1033 <th align="right">mean</th>
1034 <th align="right">sd</th>
1035 <th align="right">p0</th>
1036 <th align="right">p25</th>
1037 <th align="right">p50</th>
1038 <th align="right">p75</th>
1039 <th align="right">p100</th>
1040 <th align="left">hist</th>
1041 </tr>
1042 </thead>
1043 <tbody>
1044 <tr class="odd">
1045 <td align="left">age</td>
1046 <td align="right">0</td>
1047 <td align="right">1</td>
1048 <td align="right">922.14</td>
1049 <td align="right">491.86</td>
1050 <td align="right">118</td>
1051 <td align="right">484.0</td>
1052 <td align="right">1004</td>
1053 <td align="right">1372.0</td>
1054 <td align="right">1582</td>
1055 <td align="left">▃▇▁▇▇</td>
1056 </tr>
1057 <tr class="even">
1058 <td align="left">circumference</td>
1059 <td align="right">0</td>
1060 <td align="right">1</td>
1061 <td align="right">115.86</td>
1062 <td align="right">57.49</td>
1063 <td align="right">30</td>
1064 <td align="right">65.5</td>
1065 <td align="right">115</td>
1066 <td align="right">161.5</td>
1067 <td align="right">214</td>
1068 <td align="left">▇▃▇▇▅</td>
1069 </tr>
1070 </tbody>
1071 </table>
1072 </div>
1073 <div id="customizing-print-options" class="section level2">
1074 <h2>Customizing print options</h2>
1075 <p>Although its not a common use case outside of writing vignettes about
1076 <code>skimr</code>, you can fall back to default printing methods by
1077 adding the chunk option <code>render = knitr::normal_print</code>.</p>
1078 <p>You can also disable the <code>skimr</code> summary by setting the
1079 chunk option <code>skimr_include_summary = FALSE</code>.</p>
1080 <p>You can change the number of digits shown in the columns of generated
1081 statistics by changing the <code>skimr_digits</code> chunk option.</p>
1082 </div>
1083 <div id="modifying-skim" class="section level2">
1084 <h2>Modifying <code>skim()</code></h2>
1085 <p><code>skimr</code> is opinionated in its choice of defaults, but
1086 users can easily add, replace, or remove the statistics for a class. For
1087 interactive use, you can create your own skimming function with the
1088 <code>skim_with()</code> factory. <code>skimr</code> also has an API for
1089 extensions in other packages. Working with that is covered later.</p>
1090 <p>To add a statistic for a data type, create an <code>sfl()</code> (a
1091 <code>skimr</code> function list) for each class that you want to
1092 change:</p>
1093 <div class="sourceCode" id="cb63"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb63-1"><a href="#cb63-1" tabindex="-1"></a>my_skim <span class="ot">&lt;-</span> <span class="fu">skim_with</span>(<span class="at">numeric =</span> <span class="fu">sfl</span>(<span class="at">new_mad =</span> mad))</span>
1094 <span id="cb63-2"><a href="#cb63-2" tabindex="-1"></a><span class="fu">my_skim</span>(faithful)</span></code></pre></div>
1095 <table>
1096 <caption>Data summary</caption>
1097 <tbody>
1098 <tr class="odd">
1099 <td align="left">Name</td>
1100 <td align="left">faithful</td>
1101 </tr>
1102 <tr class="even">
1103 <td align="left">Number of rows</td>
1104 <td align="left">272</td>
1105 </tr>
1106 <tr class="odd">
1107 <td align="left">Number of columns</td>
1108 <td align="left">2</td>
1109 </tr>
1110 <tr class="even">
1111 <td align="left">_______________________</td>
1112 <td align="left"></td>
1113 </tr>
1114 <tr class="odd">
1115 <td align="left">Column type frequency:</td>
1116 <td align="left"></td>
1117 </tr>
1118 <tr class="even">
1119 <td align="left">numeric</td>
1120 <td align="left">2</td>
1121 </tr>
1122 <tr class="odd">
1123 <td align="left">________________________</td>
1124 <td align="left"></td>
1125 </tr>
1126 <tr class="even">
1127 <td align="left">Group variables</td>
1128 <td align="left">None</td>
1129 </tr>
1130 </tbody>
1131 </table>
1132 <p><strong>Variable type: numeric</strong></p>
1133 <table>
1134 <colgroup>
1135 <col width="15%" />
1136 <col width="11%" />
1137 <col width="15%" />
1138 <col width="6%" />
1139 <col width="6%" />
1140 <col width="5%" />
1141 <col width="6%" />
1142 <col width="4%" />
1143 <col width="6%" />
1144 <col width="5%" />
1145 <col width="6%" />
1146 <col width="8%" />
1147 </colgroup>
1148 <thead>
1149 <tr class="header">
1150 <th align="left">skim_variable</th>
1151 <th align="right">n_missing</th>
1152 <th align="right">complete_rate</th>
1153 <th align="right">mean</th>
1154 <th align="right">sd</th>
1155 <th align="right">p0</th>
1156 <th align="right">p25</th>
1157 <th align="right">p50</th>
1158 <th align="right">p75</th>
1159 <th align="right">p100</th>
1160 <th align="left">hist</th>
1161 <th align="right">new_mad</th>
1162 </tr>
1163 </thead>
1164 <tbody>
1165 <tr class="odd">
1166 <td align="left">eruptions</td>
1167 <td align="right">0</td>
1168 <td align="right">1</td>
1169 <td align="right">3.49</td>
1170 <td align="right">1.14</td>
1171 <td align="right">1.6</td>
1172 <td align="right">2.16</td>
1173 <td align="right">4</td>
1174 <td align="right">4.45</td>
1175 <td align="right">5.1</td>
1176 <td align="left">▇▂▂▇▇</td>
1177 <td align="right">0.95</td>
1178 </tr>
1179 <tr class="even">
1180 <td align="left">waiting</td>
1181 <td align="right">0</td>
1182 <td align="right">1</td>
1183 <td align="right">70.90</td>
1184 <td align="right">13.59</td>
1185 <td align="right">43.0</td>
1186 <td align="right">58.00</td>
1187 <td align="right">76</td>
1188 <td align="right">82.00</td>
1189 <td align="right">96.0</td>
1190 <td align="left">▃▃▂▇▂</td>
1191 <td align="right">11.86</td>
1192 </tr>
1193 </tbody>
1194 </table>
1195 <p>As the previous example suggests, the default is to append
1196 <em>new</em> summary statistics to the preexisting set. This behavior
1197 isn’t always desirable, especially when you want lots of changes. To
1198 stop appending, set <code>append = FALSE</code>.</p>
1199 <div class="sourceCode" id="cb64"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb64-1"><a href="#cb64-1" tabindex="-1"></a>my_skim <span class="ot">&lt;-</span> <span class="fu">skim_with</span>(<span class="at">numeric =</span> <span class="fu">sfl</span>(<span class="at">new_mad =</span> mad), <span class="at">append =</span> <span class="cn">FALSE</span>)</span>
1200 <span id="cb64-2"><a href="#cb64-2" tabindex="-1"></a><span class="fu">my_skim</span>(faithful)</span></code></pre></div>
1201 <table>
1202 <caption>Data summary</caption>
1203 <tbody>
1204 <tr class="odd">
1205 <td align="left">Name</td>
1206 <td align="left">faithful</td>
1207 </tr>
1208 <tr class="even">
1209 <td align="left">Number of rows</td>
1210 <td align="left">272</td>
1211 </tr>
1212 <tr class="odd">
1213 <td align="left">Number of columns</td>
1214 <td align="left">2</td>
1215 </tr>
1216 <tr class="even">
1217 <td align="left">_______________________</td>
1218 <td align="left"></td>
1219 </tr>
1220 <tr class="odd">
1221 <td align="left">Column type frequency:</td>
1222 <td align="left"></td>
1223 </tr>
1224 <tr class="even">
1225 <td align="left">numeric</td>
1226 <td align="left">2</td>
1227 </tr>
1228 <tr class="odd">
1229 <td align="left">________________________</td>
1230 <td align="left"></td>
1231 </tr>
1232 <tr class="even">
1233 <td align="left">Group variables</td>
1234 <td align="left">None</td>
1235 </tr>
1236 </tbody>
1237 </table>
1238 <p><strong>Variable type: numeric</strong></p>
1239 <table>
1240 <thead>
1241 <tr class="header">
1242 <th align="left">skim_variable</th>
1243 <th align="right">n_missing</th>
1244 <th align="right">complete_rate</th>
1245 <th align="right">new_mad</th>
1246 </tr>
1247 </thead>
1248 <tbody>
1249 <tr class="odd">
1250 <td align="left">eruptions</td>
1251 <td align="right">0</td>
1252 <td align="right">1</td>
1253 <td align="right">0.95</td>
1254 </tr>
1255 <tr class="even">
1256 <td align="left">waiting</td>
1257 <td align="right">0</td>
1258 <td align="right">1</td>
1259 <td align="right">11.86</td>
1260 </tr>
1261 </tbody>
1262 </table>
1263 <p>You can also use <code>skim_with()</code> to remove specific
1264 statistics by setting them to <code>NULL</code>. This is commonly used
1265 to disable the inline histograms and spark graphs.</p>
1266 <div class="sourceCode" id="cb65"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb65-1"><a href="#cb65-1" tabindex="-1"></a>no_hist <span class="ot">&lt;-</span> <span class="fu">skim_with</span>(<span class="at">ts =</span> <span class="fu">sfl</span>(<span class="at">line_graph =</span> <span class="cn">NULL</span>))</span>
1267 <span id="cb65-2"><a href="#cb65-2" tabindex="-1"></a><span class="fu">no_hist</span>(Nile)</span></code></pre></div>
1268 <table>
1269 <caption>Data summary</caption>
1270 <tbody>
1271 <tr class="odd">
1272 <td align="left">Name</td>
1273 <td align="left">Nile</td>
1274 </tr>
1275 <tr class="even">
1276 <td align="left">Number of rows</td>
1277 <td align="left">100</td>
1278 </tr>
1279 <tr class="odd">
1280 <td align="left">Number of columns</td>
1281 <td align="left">1</td>
1282 </tr>
1283 <tr class="even">
1284 <td align="left">_______________________</td>
1285 <td align="left"></td>
1286 </tr>
1287 <tr class="odd">
1288 <td align="left">Column type frequency:</td>
1289 <td align="left"></td>
1290 </tr>
1291 <tr class="even">
1292 <td align="left">ts</td>
1293 <td align="left">1</td>
1294 </tr>
1295 <tr class="odd">
1296 <td align="left">________________________</td>
1297 <td align="left"></td>
1298 </tr>
1299 <tr class="even">
1300 <td align="left">Group variables</td>
1301 <td align="left">None</td>
1302 </tr>
1303 </tbody>
1304 </table>
1305 <p><strong>Variable type: ts</strong></p>
1306 <table style="width:100%;">
1307 <colgroup>
1308 <col width="14%" />
1309 <col width="10%" />
1310 <col width="14%" />
1311 <col width="6%" />
1312 <col width="5%" />
1313 <col width="10%" />
1314 <col width="7%" />
1315 <col width="7%" />
1316 <col width="7%" />
1317 <col width="4%" />
1318 <col width="5%" />
1319 <col width="7%" />
1320 </colgroup>
1321 <thead>
1322 <tr class="header">
1323 <th align="left">skim_variable</th>
1324 <th align="right">n_missing</th>
1325 <th align="right">complete_rate</th>
1326 <th align="right">start</th>
1327 <th align="right">end</th>
1328 <th align="right">frequency</th>
1329 <th align="right">deltat</th>
1330 <th align="right">mean</th>
1331 <th align="right">sd</th>
1332 <th align="right">min</th>
1333 <th align="right">max</th>
1334 <th align="right">median</th>
1335 </tr>
1336 </thead>
1337 <tbody>
1338 <tr class="odd">
1339 <td align="left">x</td>
1340 <td align="right">0</td>
1341 <td align="right">1</td>
1342 <td align="right">1871</td>
1343 <td align="right">1970</td>
1344 <td align="right">1</td>
1345 <td align="right">1</td>
1346 <td align="right">919.35</td>
1347 <td align="right">169.23</td>
1348 <td align="right">456</td>
1349 <td align="right">1370</td>
1350 <td align="right">893.5</td>
1351 </tr>
1352 </tbody>
1353 </table>
1354 <p>The same pattern applies to changing skimmers for multiple classes
1355 simultaneously. If you want to partially-apply function arguments, use
1356 the Tidyverse lambda syntax.</p>
1357 <div class="sourceCode" id="cb66"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb66-1"><a href="#cb66-1" tabindex="-1"></a>my_skim <span class="ot">&lt;-</span> <span class="fu">skim_with</span>(</span>
1358 <span id="cb66-2"><a href="#cb66-2" tabindex="-1"></a> <span class="at">numeric =</span> <span class="fu">sfl</span>(<span class="at">total =</span> <span class="sc">~</span> <span class="fu">sum</span>(., <span class="at">na.rm =</span> <span class="cn">TRUE</span>)),</span>
1359 <span id="cb66-3"><a href="#cb66-3" tabindex="-1"></a> <span class="at">factor =</span> <span class="fu">sfl</span>(<span class="at">missing =</span> <span class="sc">~</span> <span class="fu">sum</span>(<span class="fu">is.na</span>(.))),</span>
1360 <span id="cb66-4"><a href="#cb66-4" tabindex="-1"></a> <span class="at">append =</span> <span class="cn">FALSE</span></span>
1361 <span id="cb66-5"><a href="#cb66-5" tabindex="-1"></a>)</span>
1362 <span id="cb66-6"><a href="#cb66-6" tabindex="-1"></a></span>
1363 <span id="cb66-7"><a href="#cb66-7" tabindex="-1"></a><span class="fu">my_skim</span>(iris)</span></code></pre></div>
1364 <table>
1365 <caption>Data summary</caption>
1366 <tbody>
1367 <tr class="odd">
1368 <td align="left">Name</td>
1369 <td align="left">iris</td>
1370 </tr>
1371 <tr class="even">
1372 <td align="left">Number of rows</td>
1373 <td align="left">150</td>
1374 </tr>
1375 <tr class="odd">
1376 <td align="left">Number of columns</td>
1377 <td align="left">5</td>
1378 </tr>
1379 <tr class="even">
1380 <td align="left">_______________________</td>
1381 <td align="left"></td>
1382 </tr>
1383 <tr class="odd">
1384 <td align="left">Column type frequency:</td>
1385 <td align="left"></td>
1386 </tr>
1387 <tr class="even">
1388 <td align="left">factor</td>
1389 <td align="left">1</td>
1390 </tr>
1391 <tr class="odd">
1392 <td align="left">numeric</td>
1393 <td align="left">4</td>
1394 </tr>
1395 <tr class="even">
1396 <td align="left">________________________</td>
1397 <td align="left"></td>
1398 </tr>
1399 <tr class="odd">
1400 <td align="left">Group variables</td>
1401 <td align="left">None</td>
1402 </tr>
1403 </tbody>
1404 </table>
1405 <p><strong>Variable type: factor</strong></p>
1406 <table>
1407 <thead>
1408 <tr class="header">
1409 <th align="left">skim_variable</th>
1410 <th align="right">n_missing</th>
1411 <th align="right">complete_rate</th>
1412 <th align="right">missing</th>
1413 </tr>
1414 </thead>
1415 <tbody>
1416 <tr class="odd">
1417 <td align="left">Species</td>
1418 <td align="right">0</td>
1419 <td align="right">1</td>
1420 <td align="right">0</td>
1421 </tr>
1422 </tbody>
1423 </table>
1424 <p><strong>Variable type: numeric</strong></p>
1425 <table>
1426 <thead>
1427 <tr class="header">
1428 <th align="left">skim_variable</th>
1429 <th align="right">n_missing</th>
1430 <th align="right">complete_rate</th>
1431 <th align="right">total</th>
1432 </tr>
1433 </thead>
1434 <tbody>
1435 <tr class="odd">
1436 <td align="left">Sepal.Length</td>
1437 <td align="right">0</td>
1438 <td align="right">1</td>
1439 <td align="right">876.5</td>
1440 </tr>
1441 <tr class="even">
1442 <td align="left">Sepal.Width</td>
1443 <td align="right">0</td>
1444 <td align="right">1</td>
1445 <td align="right">458.6</td>
1446 </tr>
1447 <tr class="odd">
1448 <td align="left">Petal.Length</td>
1449 <td align="right">0</td>
1450 <td align="right">1</td>
1451 <td align="right">563.7</td>
1452 </tr>
1453 <tr class="even">
1454 <td align="left">Petal.Width</td>
1455 <td align="right">0</td>
1456 <td align="right">1</td>
1457 <td align="right">179.9</td>
1458 </tr>
1459 </tbody>
1460 </table>
1461 <p>To modify the “base” skimmers, refer to them in a similar manner.
1462 Since base skimmers are usually a small group, they must return the same
1463 type for all data types in R, <code>append</code> doesn’t apply
1464 here.</p>
1465 <div class="sourceCode" id="cb67"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb67-1"><a href="#cb67-1" tabindex="-1"></a>my_skim <span class="ot">&lt;-</span> <span class="fu">skim_with</span>(<span class="at">base =</span> <span class="fu">sfl</span>(<span class="at">length =</span> length))</span>
1466 <span id="cb67-2"><a href="#cb67-2" tabindex="-1"></a><span class="fu">my_skim</span>(faithful)</span></code></pre></div>
1467 <table>
1468 <caption>Data summary</caption>
1469 <tbody>
1470 <tr class="odd">
1471 <td align="left">Name</td>
1472 <td align="left">faithful</td>
1473 </tr>
1474 <tr class="even">
1475 <td align="left">Number of rows</td>
1476 <td align="left">272</td>
1477 </tr>
1478 <tr class="odd">
1479 <td align="left">Number of columns</td>
1480 <td align="left">2</td>
1481 </tr>
1482 <tr class="even">
1483 <td align="left">_______________________</td>
1484 <td align="left"></td>
1485 </tr>
1486 <tr class="odd">
1487 <td align="left">Column type frequency:</td>
1488 <td align="left"></td>
1489 </tr>
1490 <tr class="even">
1491 <td align="left">numeric</td>
1492 <td align="left">2</td>
1493 </tr>
1494 <tr class="odd">
1495 <td align="left">________________________</td>
1496 <td align="left"></td>
1497 </tr>
1498 <tr class="even">
1499 <td align="left">Group variables</td>
1500 <td align="left">None</td>
1501 </tr>
1502 </tbody>
1503 </table>
1504 <p><strong>Variable type: numeric</strong></p>
1505 <table style="width:100%;">
1506 <colgroup>
1507 <col width="21%" />
1508 <col width="10%" />
1509 <col width="9%" />
1510 <col width="9%" />
1511 <col width="7%" />
1512 <col width="9%" />
1513 <col width="6%" />
1514 <col width="9%" />
1515 <col width="7%" />
1516 <col width="9%" />
1517 </colgroup>
1518 <thead>
1519 <tr class="header">
1520 <th align="left">skim_variable</th>
1521 <th align="right">length</th>
1522 <th align="right">mean</th>
1523 <th align="right">sd</th>
1524 <th align="right">p0</th>
1525 <th align="right">p25</th>
1526 <th align="right">p50</th>
1527 <th align="right">p75</th>
1528 <th align="right">p100</th>
1529 <th align="left">hist</th>
1530 </tr>
1531 </thead>
1532 <tbody>
1533 <tr class="odd">
1534 <td align="left">eruptions</td>
1535 <td align="right">272</td>
1536 <td align="right">3.49</td>
1537 <td align="right">1.14</td>
1538 <td align="right">1.6</td>
1539 <td align="right">2.16</td>
1540 <td align="right">4</td>
1541 <td align="right">4.45</td>
1542 <td align="right">5.1</td>
1543 <td align="left">▇▂▂▇▇</td>
1544 </tr>
1545 <tr class="even">
1546 <td align="left">waiting</td>
1547 <td align="right">272</td>
1548 <td align="right">70.90</td>
1549 <td align="right">13.59</td>
1550 <td align="right">43.0</td>
1551 <td align="right">58.00</td>
1552 <td align="right">76</td>
1553 <td align="right">82.00</td>
1554 <td align="right">96.0</td>
1555 <td align="left">▃▃▂▇▂</td>
1556 </tr>
1557 </tbody>
1558 </table>
1559 </div>
1560 <div id="extending-skimr" class="section level2">
1561 <h2>Extending <code>skimr</code></h2>
1562 <p>Packages may wish to export their own <code>skim()</code> functions.
1563 Use <code>skim_with()</code> for this. In fact, this is how
1564 <code>skimr</code> generates its version of <code>skim()</code>.</p>
1565 <div class="sourceCode" id="cb68"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb68-1"><a href="#cb68-1" tabindex="-1"></a><span class="co">#&#39; @export</span></span>
1566 <span id="cb68-2"><a href="#cb68-2" tabindex="-1"></a>my_package_skim <span class="ot">&lt;-</span> <span class="fu">skim_with</span>()</span></code></pre></div>
1567 <p>Alternatively, defaults for another data types can be added to
1568 <code>skimr</code> with the <code>get_skimmers</code> generic. The
1569 method for your data type should return an <code>sfl()</code>. Unlike
1570 the <code>sfl()</code> used interactively, you also need to set the
1571 <code>skim_type</code> argument. It should match the method type in the
1572 function signature.</p>
1573 <div class="sourceCode" id="cb69"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb69-1"><a href="#cb69-1" tabindex="-1"></a>get_skimmers.my_type <span class="ot">&lt;-</span> <span class="cf">function</span>(column) {</span>
1574 <span id="cb69-2"><a href="#cb69-2" tabindex="-1"></a> <span class="fu">sfl</span>(</span>
1575 <span id="cb69-3"><a href="#cb69-3" tabindex="-1"></a> <span class="at">skim_type =</span> <span class="st">&quot;my_type&quot;</span>,</span>
1576 <span id="cb69-4"><a href="#cb69-4" tabindex="-1"></a> <span class="at">total =</span> sum</span>
1577 <span id="cb69-5"><a href="#cb69-5" tabindex="-1"></a> )</span>
1578 <span id="cb69-6"><a href="#cb69-6" tabindex="-1"></a>}</span>
1579 <span id="cb69-7"><a href="#cb69-7" tabindex="-1"></a></span>
1580 <span id="cb69-8"><a href="#cb69-8" tabindex="-1"></a>my_data <span class="ot">&lt;-</span> <span class="fu">data.frame</span>(</span>
1581 <span id="cb69-9"><a href="#cb69-9" tabindex="-1"></a> <span class="at">my_type =</span> <span class="fu">structure</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="at">class =</span> <span class="fu">c</span>(<span class="st">&quot;my_type&quot;</span>, <span class="st">&quot;integer&quot;</span>))</span>
1582 <span id="cb69-10"><a href="#cb69-10" tabindex="-1"></a>)</span>
1583 <span id="cb69-11"><a href="#cb69-11" tabindex="-1"></a><span class="fu">skim</span>(my_data)</span></code></pre></div>
1584 <table>
1585 <caption>Data summary</caption>
1586 <tbody>
1587 <tr class="odd">
1588 <td align="left">Name</td>
1589 <td align="left">my_data</td>
1590 </tr>
1591 <tr class="even">
1592 <td align="left">Number of rows</td>
1593 <td align="left">3</td>
1594 </tr>
1595 <tr class="odd">
1596 <td align="left">Number of columns</td>
1597 <td align="left">1</td>
1598 </tr>
1599 <tr class="even">
1600 <td align="left">_______________________</td>
1601 <td align="left"></td>
1602 </tr>
1603 <tr class="odd">
1604 <td align="left">Column type frequency:</td>
1605 <td align="left"></td>
1606 </tr>
1607 <tr class="even">
1608 <td align="left">my_type</td>
1609 <td align="left">1</td>
1610 </tr>
1611 <tr class="odd">
1612 <td align="left">________________________</td>
1613 <td align="left"></td>
1614 </tr>
1615 <tr class="even">
1616 <td align="left">Group variables</td>
1617 <td align="left">None</td>
1618 </tr>
1619 </tbody>
1620 </table>
1621 <p><strong>Variable type: my_type</strong></p>
1622 <table>
1623 <thead>
1624 <tr class="header">
1625 <th align="left">skim_variable</th>
1626 <th align="right">n_missing</th>
1627 <th align="right">complete_rate</th>
1628 <th align="right">total</th>
1629 </tr>
1630 </thead>
1631 <tbody>
1632 <tr class="odd">
1633 <td align="left">my_type</td>
1634 <td align="right">0</td>
1635 <td align="right">1</td>
1636 <td align="right">6</td>
1637 </tr>
1638 </tbody>
1639 </table>
1640 <p>An extended example is available in the vignette <em>Supporting
1641 additional objects</em>.</p>
1642 </div>
1643 <div id="solutions-to-common-rendering-problems" class="section level2">
1644 <h2>Solutions to common rendering problems</h2>
1645 <p>The details of rendering are dependent on the operating system R is
1646 running on, the locale of the installation, and the fonts installed.
1647 Rendering may also differ based on whether it occurs in the console or
1648 when knitting to specific types of documents such as HTML and PDF.</p>
1649 <p>The most commonly reported problems involve rendering the spark
1650 graphs (inline histogram and line chart) on Windows. One common fix is
1651 to switch your locale. The function
1652 <code>fix_windows_histograms()</code> does this for you.</p>
1653 <p>In order to render the sparkgraphs in html or PDF histogram you may
1654 need to change fonts to one that supports blocks or Braille (depending
1655 on which you need). Please review the separate vignette and associated
1656 template for details.</p>
1657 </div>
1658
1659
1660
1661 <!-- code folding -->
1662
1663
1664 <!-- dynamically load mathjax for compatibility with self-contained -->
1665 <script>
1666 (function () {
1667 var script = document.createElement("script");
1668 script.type = "text/javascript";
1669 script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
1670 document.getElementsByTagName("head")[0].appendChild(script);
1671 })();
1672 </script>
1673
1674 </body>
1675 </html>