Created
May 30, 2017 01:12
-
-
Save elinw/05644db3d42c731f598e1baf389f86e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
skim.data.frame <- function(.data) { | |
rows <- purrr::map(.data, skim_v) | |
combined <- dplyr::bind_rows(rows, .id = "var") | |
return(structure(combined, class = c("skim_df", class(combined)))) | |
} | |
skim.grouped_df <- function(.data){ | |
nested_df <- .data %>% | |
tidyr::nest() | |
groups <- as.character(dplyr::groups(.data)) | |
group_values <- purrrlyr::by_row(nested_df[, groups], ~dplyr::combine(.)) | |
skim_df <- nested_df %>% | |
dplyr::mutate(stats = purrr::map(data, skim)) %>% | |
dplyr::mutate(stats = purrr::map2(stats, | |
group_values$.out, | |
~append_group_vars(.x, .y, groups = groups))) | |
combined <- dplyr::bind_rows(skim_df$stats) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment