You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+ Built-in translations exist for French, Portuguese, Spanish, Russian, and
118
-
Turkish. Users can easily add custom translations or modify existing ones
119
-
as needed
118
+
Turkish. Users can easily add custom translations or modify existing
119
+
languages at will
120
120
-**Flexible and extensible**:
121
-
+ The built-in features used to support alternate languages provide a way to
122
-
modify a great number of terms used in outputs (headings and tables)
123
121
+**Pipe operators** from
124
122
[magrittr](https://cran.r-project.org/package=magrittr) (`%>%`, `%$%`) and
125
123
[pipeR](https://cran.r-project.org/package=pipeR) (`%>>%`) are fully
@@ -130,6 +128,12 @@ Results can be
130
128
+**By-group processing** is easily achieved using the package's `stby()`
131
129
function which is a slightly modified version of `base::by()`, but
132
130
`dplyr::group_by()` is also supported
131
+
+ Version 1.1 introduced support for **labelled vectors** (classes *labelled*
132
+
/ *haven_labelled*), which are being treated as factors in `freq()`, and
133
+
in `dfSummary()` when all values are labelled. A future release will have
134
+
`ctable()` behave similarly.
135
+
+ Parameter `na.val` allows treating a special value as `NA` in `freq()`,
136
+
`ctable()` and `dfSummary()` (feature introduced in version 1.1.0).
133
137
+[**Pander options**](http://rapporter.github.io/pander/) can be used to
134
138
customize or enhance plain text and markdown tables
135
139
+ Base R's `format()` arguments are also supported by **summarytools**'
@@ -567,8 +571,10 @@ dfs$Variable <- NULL # This deletes the Variable column
567
571
# 6. Grouped Statistics: stby()
568
572
569
573
To produce optimal results, **summarytools** has its own version of
570
-
the base `by()` function. It's called `stby()`, and we use it exactly as we
571
-
would `by()`:
574
+
the base `by()` function. It's called `stby()`, and we use it as we
575
+
would `by()`, with a notable difference: set the `useNA` parameter to `TRUE`
576
+
to create an additional group for observations containing `NA`s on the grouping variable(s) (see example in section 6.2).
577
+
572
578
573
579
```{r}
574
580
(iris_stats_by_species <- stby(data = iris,
@@ -578,6 +584,7 @@ would `by()`:
578
584
transpose = TRUE))
579
585
```
580
586
587
+
581
588
## 6.1 Special Case of descr() with stby()
582
589
583
590
When used to produce split-group statistics for a single variable, `stby()`
@@ -589,7 +596,8 @@ with(tobacco,
589
596
stby(data = BMI,
590
597
INDICES = age.gr,
591
598
FUN = descr,
592
-
stats = c("mean", "sd", "min", "med", "max"))
599
+
stats = c("mean", "sd", "min", "med", "max"),
600
+
useNA = TRUE)
593
601
)
594
602
```
595
603
@@ -623,10 +631,8 @@ with(tobacco,
623
631
624
632
To create grouped statistics with `freq()`, `descr()` or `dfSummary()`, it is
625
633
possible to use **dplyr**'s `group_by()` as an alternative to `stby()`.
626
-
Syntactic differences aside, one key distinction is that `group_by()` considers
627
-
`NA` values on the grouping variable(s) as a valid category, albeit with a
628
-
warning suggesting the use of `forcats::fct_na_value_to_level` to make
629
-
`NA`'s explicit in factors. Following this advice, we get:
634
+
Usings `forcats::fct_na_value_to_level` to make `NA`'s explicit in factors is
635
+
recommended:
630
636
631
637
```{r, eval=FALSE}
632
638
library(dplyr)
@@ -1263,8 +1269,8 @@ The package comes with no guarantees. It is a work in progress and
1263
1269
feedback is welcome. Please open an [issue on GitHub](https://github.com/dcomtois/summarytools/issues) if you find a
1264
1270
bug or wish to submit a feature request.
1265
1271
1266
-
**summarytools** is the result of **many** hours of work. If you find the
1267
-
package brings value to your work, please take a moment to make a small
1272
+
**summarytools** is the result of many hours of work. If it
1273
+
brings value to your work, please consider making a small
1268
1274
donation using this [Paypal link](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=HMN3QJR7UMT7S&item_name=Help+scientists,+data+scientists+and+analysts+around+the+globe¤cy_code=CAD&source=url).
0 commit comments