skimr: how to remove histogram?

匆匆过客 提交于 2019-12-11 08:41:25

问题


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.



来源:https://stackoverflow.com/questions/51340323/skimr-how-to-remove-histogram

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!