Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glimpse2 #7

Open
maurolepore opened this issue Oct 8, 2018 · 0 comments
Open

glimpse2 #7

maurolepore opened this issue Oct 8, 2018 · 0 comments

Comments

@maurolepore
Copy link
Contributor

glimpse2 <- function(.data) {
  purrr::imap_dfr(
    .data, 
    ~tibble::tibble(
      name = .y,
      type = typeof(.x),
      unique_head = paste0(as.character(head(unique(.x))), collapse = ", ")
    )
  )
}

print(glimpse2(mtcars),n = 40)
#> # A tibble: 11 x 3
#>    name  type   unique_head                             
#>    <chr> <chr>  <chr>                                   
#>  1 mpg   double 21, 22.8, 21.4, 18.7, 18.1, 14.3        
#>  2 cyl   double 6, 4, 8                                 
#>  3 disp  double 160, 108, 258, 360, 225, 146.7          
#>  4 hp    double 110, 93, 175, 105, 245, 62              
#>  5 drat  double 3.9, 3.85, 3.08, 3.15, 2.76, 3.21       
#>  6 wt    double 2.62, 2.875, 2.32, 3.215, 3.44, 3.46    
#>  7 qsec  double 16.46, 17.02, 18.61, 19.44, 20.22, 15.84
#>  8 vs    double 0, 1                                    
#>  9 am    double 1, 0                                    
#> 10 gear  double 4, 3, 5                                 
#> 11 carb  double 4, 1, 2, 3, 6, 8

print(glimpse2(iris),n = 40)
#> # A tibble: 5 x 3
#>   name         type    unique_head                  
#>   <chr>        <chr>   <chr>                        
#> 1 Sepal.Length double  5.1, 4.9, 4.7, 4.6, 5, 5.4   
#> 2 Sepal.Width  double  3.5, 3, 3.2, 3.1, 3.6, 3.9   
#> 3 Petal.Length double  1.4, 1.3, 1.5, 1.7, 1.6, 1.1 
#> 4 Petal.Width  double  0.2, 0.4, 0.3, 0.1, 0.5, 0.6 
#> 5 Species      integer setosa, versicolor, virginica

Created on 2018-10-08 by the reprex package (v0.2.1)

@maurolepore maurolepore transferred this issue from forestgeo/fgeo.tool Dec 30, 2018
@maurolepore maurolepore reopened this Dec 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant