skimr: how to remove histogram?

2019-07-27 00:40发布

问题:

I want to use the function skim from R package skimr on Windows. Unfortunately, in many situations column, hist is printed incorrectly (with many <U+2587>-like symbols), as in the example below.

Question: is there an easy way to either disable column "hist" and prevent it from being printed or prevent it from being calculated at all? Is there an option like hist = FALSE?

capture.output(skimr::skim(iris))
#>  [1] "Skim summary statistics"                                                                         
#>  [2] " n obs: 150 "                                                                                    
#>  [3] " n variables: 5 "                                                                                
#>  [4] ""                                                                                                
#>  [5] "-- Variable type:factor ------------------------------------------------------------------------"
#>  [6] " variable missing complete   n n_unique                       top_counts"                        
#>  [7] "  Species       0      150 150        3 set: 50, ver: 50, vir: 50, NA: 0"                        
#>  [8] " ordered"                                                                                        
#>  [9] "   FALSE"                                                                                        
#> [10] ""                                                                                                
#> [11] "-- Variable type:numeric -----------------------------------------------------------------------"
#> [12] "     variable missing complete   n mean   sd  p0 p25  p50 p75 p100"                              
#> [13] " Petal.Length       0      150 150 3.76 1.77 1   1.6 4.35 5.1  6.9"                              
#> [14] "  Petal.Width       0      150 150 1.2  0.76 0.1 0.3 1.3  1.8  2.5"                              
#> [15] " Sepal.Length       0      150 150 5.84 0.83 4.3 5.1 5.8  6.4  7.9"                              
#> [16] "  Sepal.Width       0      150 150 3.06 0.44 2   2.8 3    3.3  4.4"                              
#> [17] "     hist"                                                                                       
#> [18] " <U+2587><U+2581><U+2581><U+2582><U+2585><U+2585><U+2583><U+2581>"                               
#> [19] " <U+2587><U+2581><U+2581><U+2585><U+2583><U+2583><U+2582><U+2582>"                               
#> [20] " <U+2582><U+2587><U+2585><U+2587><U+2586><U+2585><U+2582><U+2582>"                               
#> [21] " <U+2581><U+2582><U+2585><U+2587><U+2583><U+2582><U+2581><U+2581>"

Changing the locale to Chinese (as in this answer) does not solve the problem, but makes it worse:

Sys.setlocale(locale = "Lithuanian")
df <- data.frame(x = 1:5, y = c("Ą", "Č", "Ę", "ū", "ž"))

Sys.setlocale(locale = "Chinese")
capture.output(skimr::skim(df))

#> Error in substr(names(x), 1, options$formats$.levels$max_char) : invalid multibyte string at '<c0>'

回答1:

skim_with(numeric = list(hist = NULL)) This is in the "Using Skimr" vignette.



标签: r skimr