Skip to content

Commit

Permalink
Merge develop to master
Browse files Browse the repository at this point in the history
Develop to master
  • Loading branch information
elinw authored Jan 31, 2020
2 parents 93aa2dc + a3aed1f commit daba7e8
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 197 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ Imports:
stringr (>= 1.1),
tibble (>= 2.0.0),
tidyr (>= 1.0),
tidyselect (>= 0.2.5)
tidyselect (>= 0.2.5),
withr
Suggests:
covr,
extrafont,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export(matches)
export(max_char)
export(min_char)
export(modify_default_skimmers)
export(n_complete)
export(n_empty)
export(n_missing)
export(n_unique)
Expand Down
18 changes: 11 additions & 7 deletions R/skim_print.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
#'
#' @section Controlling metadata behavior:
#'
#' By default, `skimr` removes the tibble metadata when generating output. On
#' some platforms, this can lead to all output getting removed. To disable that
#' behavior, set either `strip_metadata = FALSE` when calling print or use
#' `options(skimr_strip_metadata = FALSE)`.
#' On POSIX systems, `skimr` removes the tibble metadata when generating output.
#' On some platforms, this can lead to all output getting removed. To disable
#' that behavior, set either `strip_metadata = FALSE` when calling print or use
#' `options(skimr_strip_metadata = FALSE)`. The `crayon` package and the color
#' support within `tibble` is also a factor. If your `skimr` results tables are
#' empty you may need to run the following `options(crayon.enabled = FALSE)`.
#'
#' @inheritParams tibble:::print.tbl
#' @seealso [tibble::trunc_mat()] For a list of global options for customizing
#' print formatting.
#' print formatting. [crayon::has_color()] for the variety of issues that
#' affect tibble's color support.
#' @param include_summary Whether a summary of the data frame should be printed
#' @param strip_metadata Whether tibble metadata should be removed.
#' @param rule_width Width of the cli rules in printed skim object. Defaults
Expand All @@ -45,11 +48,12 @@ print.skim_df <- function(x,
width = Inf,
n_extra = NULL,
strip_metadata = getOption(
"skimr_strip_metadata", TRUE
"skimr_strip_metadata", FALSE
),
rule_width = base::options()$width,
summary_rule_width = 40,
...) {
withr::local_options(list(crayon.enabled = FALSE))
if (is_skim_df(x)) {
if (include_summary) {
print(summary(x), .summary_rule_width = summary_rule_width, ...)
Expand All @@ -73,7 +77,7 @@ print.one_skim_df <- function(x,
.width = Inf,
n_extra = NULL,
strip_metadata = getOption(
"skimr_strip_metadata", TRUE
"skimr_strip_metadata", FALSE
),
.rule_width = base::options()$width,
...) {
Expand Down
7 changes: 7 additions & 0 deletions R/skim_with.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
#' # Or pass the same as a list, unquoting the input.
#' my_skimmers <- list(numeric = sfl(mean), character = sfl(length))
#' my_skim <- skim_with(!!!my_skimmers)
#'
#' # Use the v1 base skimmers instead.
#' my_skim <- skim_with(base = sfl(
#' missing = n_missing,
#' complete = n_complete,
#' n = length
#' ))
#' @export
skim_with <- function(...,
base = sfl(
Expand Down
7 changes: 1 addition & 6 deletions R/skimr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,19 @@
NULL

.onLoad <- function(libname, pkgname) {
options(
skimr_strip_metadata = TRUE
)
options(skimr_strip_metadata = .Platform$OS.type != "windows")
}


# Imports -----------------------------------------------------------------

#' @importFrom rlang %||%

#' @importFrom knitr knit_print

#' @importFrom magrittr %>%
#' @export
magrittr::`%>%`

#' @importFrom tidyselect contains
#' @aliases select_helpers
#' @export
tidyselect::contains

Expand Down
7 changes: 7 additions & 0 deletions R/stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ n_missing <- function(x) {
sum(is.na(x) | is.null(x))
}

#' @describeIn stats Calculate the sum of not `NA` and `NULL` (i.e. missing)
#' values.
#' @export
n_complete <- function(x) {
sum(!is.na(x) & !is.null(x))
}

#' @describeIn stats Calculate complete values; complete values are not missing.
#' @export
complete_rate <- function(x) {
Expand Down
23 changes: 19 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,29 @@ Displays in documents of different types will vary. For example, one user found
that the font "Yu Gothic UI Semilight" produced consistent results for
Microsoft Word and Libre Office Write.

### Empty results tables
### Stripping metadata and empty results tables

If your skimr results tables are empty you may need to run the following
In POSIX systems, `skimr` tries to remove the tibble metadata when producing
the results. A complicating factor is tibble's color support, which depends
on environment settings. In particular, not all Windows terminals support
colors in the way that tibble expects.

So, by default, we disable removing metadata on windows. You can turn this
feature on with an option. Either set it when calling print or globally.

```{r, eval = FALSE}
print(skimmed, strip_metadata = TRUE)
options(skimr_strip_metadata = TRUE)
```
options(crayon.enabled = FALSE)

Separately, you might need to check the option `crayon.enabled`. Similarly, if
your skimr results tables are empty you may need to run the following

```{r, eval = FALSE}
options(crayon.enabled = FALSE)
```
one time per session.

You need to do this one time per session.

## Contributing

Expand Down
Loading

0 comments on commit daba7e8

Please sign in to comment.