Debian Codegraph @

inst/other_docs/blog.md

raw symbols SCIP
1 Like every R user who uses summary statistics (so, everyone), our team
2 has to rely on some combination of summary functions beyond `summary()`
3 and `str()`. But we found them all lacking in some way because they can
4 be generic, they don’t always provide easy-to-operate-on data
5 structures, and they are not pipeable. What we wanted was a frictionless
6 approach for quickly skimming useful and tidy summary statistics as part
7 of a pipeline. And so at [rOpenSci
8 #unconf17](http://unconf17.ropensci.org/), we developed
9 [`skimr`](https://github.com/ropenscilabs/skimr#skimr).
10
11 In a nutshell, `skimr` will create a `skim_df` object that can be
12 further operated upon or that provides a human-readable printout in the
13 console. It presents reasonable default summary statistics for numerics,
14 factors, etc, and lists counts, and missing and unique values. And the
15 momentum is still going, thanks to our awesome team (see below)!
16
17 ## Backstory
18
19 The idea for skimr as a project for the #unconf17 [was proposed by
20 Amelia McNamara](https://github.com/ropensci/unconf17/issues/50)
21 following [discussions on
22 Twitter](https://twitter.com/AmeliaMN/status/774348524653834241) and an
23 [initial package Hadley Wickham](https://github.com/hadley/precis).
24
25 Once we were together in Los Angeles, we formed a solid team, set up a
26 Google Doc, a Slack channel, the `ropensci/skimr` repo, and grabbed a
27 whiteboard.
28
29 We started off by brainstorming what we liked about existing summary
30 packages and what other features we wanted. We started looking at
31 example data, `mtcars`.
32
33 Here’s what we liked and disliked, in Amelia’s words:
34
35 ``` r
36 ### "I like what we get here because mpg is numeric so these stats make sense:"
37 summary(mtcars$mpg)
38 # Min. 1st Qu. Median Mean 3rd Qu. Max.
39 # 10.40 15.42 19.20 20.09 22.80 33.90
40
41
42 ### "But I don’t like this because cyl should really be a factor and shouldn't
43 ### have these stats:"
44 summary(mtcars$cyl)
45 # Min. 1st Qu. Median Mean 3rd Qu. Max.
46 # 4.000 4.000 6.000 6.188 8.000 8.000
47
48
49 ### "This is OK, but not descriptive enough. It could be clearer what I'm
50 ### looking at."
51 mosaic::tally(~cyl, data = mtcars) # install.packages('mosaic')
52 # cyl
53 # 4 6 8
54 # 11 7 14
55
56
57 ### "But this output isn't labeled, not ideal."
58 table(mtcars$cyl, mtcars$vs)
59 #
60 # 0 1
61 # 4 1 10
62 # 6 3 4
63 # 8 14 0
64
65
66 ### "I like this because it returns 'sd', 'n' and 'missing'":
67 mosaic::favstats(~mpg, data = mtcars)
68 # min Q1 median Q3 max mean sd n missing
69 # 10.4 15.425 19.2 22.8 33.9 20.09062 6.026948 32 0
70 ```
71
72 Once we had an idea of what we thought would be useful, we did a bit of
73 market research (i.e. we made a short
74 [presentation](https://docs.google.com/presentation/d/13Ky3-Y70STzufLJtCm6GXN8SMj2Y11riDef8b9cBgAQ/edit#slide=id.p)
75 and ran it by other unconfers at lunch.
76
77 ## Introducing `skimr`
78
79 So what does `skimr` actually do? It allows you to skim useful summary
80 statistics in the console, or use those statistics in a pipeable
81 workflow.
82
83 Some features of output in the console:
84
85 - reports missing, complete, n, sd, and quantiles
86 - reports numeric/int/double separately from factor/chr, and
87 identifies class
88 - handles dates, logicals
89 - uses [Hadley’s pillars](https://github.com/hadley/pillar),
90 specifically `pillar::spark-bar()`
91
92 Here are examples of `skimr` in action:
93
94 ### Quick skim in the console:
95
96 **Nicely separates numeric and factor variables:**
97
98 ![](https://github.com/ropenscilabs/skimr/blob/24c733d7e4752c37e46e4c36693da107f42f3f55/man/figures/skim_iris.png)
99 <br>
100
101 **Clearly displays many numeric variables:**
102
103 ![](https://github.com/ropenscilabs/skimr/blob/ecb90e22047d4a1b228bcf471650eb79b733e52e/man/figures/skim_mtcars.png)
104 <br>
105
106 **Also works with strings:**
107
108 ![](https://github.com/ropenscilabs/skimr/blob/ecb90e22047d4a1b228bcf471650eb79b733e52e/man/figures/skim_babynames.png)
109 <br>
110
111 ### Exploring a skim_df object
112
113 By default `skim` prints beautifully in the console, but it also
114 produces a long, tidy-format `skim_df` object that can be computed on.
115
116 ``` r
117 a <- skim(chickwts)
118 dim(a)
119 # [1] 22 5
120 View(a)
121 ```
122
123 <img src="https://github.com/ropenscilabs/skimr/blob/ecb90e22047d4a1b228bcf471650eb79b733e52e/man/figures/skim_chickwts_df.png" width="450px">
124
125 ### Computing with the skim_df object
126
127 Maybe you just want to skim a specific portion of your data frame. Use
128 skimr with a pipe!
129
130 ``` r
131 skim(mtcars) |> filter(stat == "hist")
132 # A tibble: 11 × 5
133 # var type stat level value
134 # <chr> <chr> <chr> <chr> <dbl>
135 # 1 mpg numeric hist ▂▅▇▇▇▃▁▁▂▂ 0
136 # 2 cyl numeric hist ▆▁▁▁▃▁▁▁▁▇ 0
137 # 3 disp numeric hist ▇▇▅▁▁▇▃▂▁▃ 0
138 # 4 hp numeric hist ▆▆▇▂▇▂▃▁▁▁ 0
139 # 5 drat numeric hist ▃▇▂▂▃▆▅▁▁▁ 0
140 # 6 wt numeric hist ▂▂▂▂▇▆▁▁▁▂ 0
141 # 7 qsec numeric hist ▂▃▇▇▇▅▅▁▁▁ 0
142 # 8 vs numeric hist ▇▁▁▁▁▁▁▁▁▆ 0
143 # 9 am numeric hist ▇▁▁▁▁▁▁▁▁▆ 0
144 # 10 gear numeric hist ▇▁▁▁▆▁▁▁▁▂ 0
145 # 11 carb numeric hist ▆▇▂▁▇▁▁▁▁▁ 0
146 ```
147
148 ### Specifying your own statistics
149
150 Another possibility is specifying your own statistics to display with
151 `skimr`:
152
153 ``` r
154 funs <- list(
155 iqr = IQR,
156 quantile = purrr::partial(quantile, probs = .99)
157 )
158 skim_with(numeric = funs, append = FALSE)
159 skim_v(iris$Sepal.Length)
160
161 # A tibble: 2 × 4
162 # type stat level value
163 # <chr> <chr> <chr> <dbl>
164 # 1 numeric iqr .all 1.3
165 # 2 numeric quantile 99% 7.7
166 ```
167
168 ## Our awesome team
169
170 We had a really fantastic team with diverse backgrounds, and it was
171 really cool how organically everyone found a role for themselves during
172 the development of `skimr`. Between brainstorming sessions, experienced
173 coders began to iteratively develop the code while others worked on
174 documentation and tests, and got more involved. Everyone asked questions
175 and brainstormed together; it was a really welcoming environment. We
176 knew that by the end of the second day of the unconf, we would present
177 our work using only the repo’s
178 [README](https://github.com/ropenscilabs/skimr#skimr) file. So we
179 focused on communication throughout the entire development process.
180
181 A lot of the heavy lifting at the unconf was done by Michael, Elin, and
182 Eduardo, and Elin has continued leading development in the month since!
183
184 This was the original team in alphabetical order. We have also had many
185 virtual contributors as well: see the full list of contributors
186 [here](https://github.com/ropenscilabs/skimr/graphs/contributors).
187
188 **Eduardo Arino de la Rubia**
189 Job Title: Chief Data Scientist at Domino Data Lab
190 Project Contributions: Coder
191
192 **Shannon Ellis**
193 Job Title: Postdoctoral fellow in the Biostatistics Department at the
194 Johns Hopkins Bloomberg School of Public Health
195 Project Contributions: Test Scripts
196
197 **Julia Stewart Lowndes**
198 Job Title: Marine Data Scientist at the National Center for Ecological
199 Analysis and Synthesis
200 Project Contributions: Documentation and test scripts
201
202 **Hope McLeod**
203 Job Title: Data Engineer at Kobalt Music
204 Project Contributions: Documentation
205
206 **Amelia McNamara**
207 Job Title: Visiting Assistant Professor of Statistical & Data Sciences
208 at Smith College
209 Project Contributions: Coder
210
211 **Michael Quinn**
212 Job Title: Quantitative Analyst at Google
213 Project Contributions: Coder
214
215 **Elin Waring**
216 Job Title: Professor at Lehman College Sociology Department, City
217 University of New York
218 Project Contributions: Coder
219
220 **Hao Zhu**
221 Job Title: Programmer Analyst at the Institute for Aging Research
222 Project Contributions: Coder
223
224 ## In summary (ha…)
225
226 The work we did together was only possible because of rOpenSci’s
227 incredible community and culture. For us to be able to dream up
228 something we wanted to build and have the time and space to actually do
229 it together was really exciting. So thank you rOpenSci and everyone in
230 the greater community!
231
232 There is more work to be done on `skimr`, so please check out the
233 [`skimr`](https://github.com/ropenscilabs/skimr) repo for the latest
234 features and improvements!
235
236 Updated to use the base pipe.