Guest User

Untitled

a guest
Mar 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. ```R
  2. #' Help to create a list for the argument `col_types` of [readr::read_csv()].
  3. #' @noRd
  4. cat_col_types <- function(x) {
  5. types <- purrr::map(x, class) %>%
  6. tibble::enframe() %>%
  7. tidyr::unnest() %>%
  8. dplyr::mutate(
  9. type = dplyr::case_when(
  10. value == "character" ~ "c",
  11. value == "integer" ~ "i",
  12. value == "numeric" ~ "d"
  13. ),
  14. type = paste0(name, " = '", type, "',")
  15. ) %>%
  16. dplyr::pull(type)
  17.  
  18. cat(types)
  19. }
  20. ```
Add Comment
Please, Sign In to add comment