Skip to content

Commit

Permalink
Lints and style
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquinn32 committed Dec 22, 2022
1 parent c004d4d commit 5bb80df
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions R/skim_with.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ skim_with <- function(...,
data_rows = nrow(data),
data_cols = ncol(data),
df_name = .data_name,
dt_key = get_dt_key(data),
dt_key = get_dt_key(data),
groups = dplyr::group_vars(data),
base_skimmers = names(base$funs),
skimmers_used = get_skimmers_used(unique_skimmers)
Expand Down Expand Up @@ -166,7 +166,7 @@ validate_assignment <- function(...) {
defaults <- get_default_skimmers()
existing <- proposed_names %in% names(defaults)

if (!all(existing) & length(defaults) > 0) {
if (!all(existing) && length(defaults) > 0) {
collapsed <- paste(proposed_names[!existing], collapse = ", ")
message(
"Creating new skimming functions for the following classes: ",
Expand Down Expand Up @@ -262,9 +262,8 @@ get_local_skimmers <- function(classes, local_skimmers) {
if (length(local_classes) == 0) {
return(NULL)
}

first_class <- local_classes[[1]]

out <- local_skimmers[[first_class]]
out$skim_type <- first_class
out
Expand All @@ -274,7 +273,9 @@ merge_skimmers <- function(locals, defaults, append) {
if (!append || locals$skim_type != defaults$skim_type) {
locals
} else {
defaults$funs <- purrr::compact(purrr::list_modify(defaults$funs, !!!locals$funs))
defaults$funs <- purrr::compact(purrr::list_modify(
defaults$funs, !!!locals$funs
))
defaults
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-skim_with.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test_that("Doubles and integers are both 'numeric'", {
df <- data.frame(int = 1:3, dbl = 1:3 + 0.5)
my_skim <- skim_with(numeric = sfl(hist = NULL))
input <- my_skim(df)

expect_false("numeric.hist" %in% names(input))
expect_equal(
attr(input, "skimmers_used")$numeric,
Expand Down
9 changes: 5 additions & 4 deletions vignettes/skimr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ a skim_df.

```{r}
skim(iris) %>% is_skim_df()
```

```{r, render = knitr::normal_print}
skim(iris) %>%
dplyr::select(-skim_type, -skim_variable) %>% is_skim_df()
dplyr::select(-skim_type, -skim_variable) %>%
is_skim_df()
```

```{r, render = knitr::normal_print}
skim(iris) %>%
dplyr::select(-n_missing) %>% is_skim_df()
dplyr::select(-n_missing) %>%
is_skim_df()
```

In order to avoid type coercion, columns for summary statistics for different
Expand Down Expand Up @@ -250,7 +251,7 @@ object in `skimr` v1.
```{r, render = knitr::normal_print}
iris %>%
skim() %>%
to_long() %>%
to_long() %>%
head()
```

Expand Down

0 comments on commit 5bb80df

Please sign in to comment.