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

Printing of precis() histograms on Windows #274

Closed
bwiernik opened this issue Sep 8, 2020 · 3 comments
Closed

Printing of precis() histograms on Windows #274

bwiernik opened this issue Sep 8, 2020 · 3 comments

Comments

@bwiernik
Copy link

bwiernik commented Sep 8, 2020

On Windows, R's longstanding limitations with printing UTF-8 characters means that the histograms are corrupted and render like <U+2581>.

rethinking::precis(cars)
#>        mean        sd 5.5%  94.5%
#> speed 15.40  5.287644    7 24.000
#> dist  42.98 25.769377   10 87.135
#>                                                                                              histogram
#> speed         <U+2582><U+2582><U+2583><U+2585><U+2587><U+2585><U+2587><U+2587><U+2581><U+2585><U+2581>
#> dist  <U+2582><U+2583><U+2585><U+2587><U+2583><U+2583><U+2582><U+2581><U+2581><U+2581><U+2581><U+2581>

Created on 2020-09-07 by the reprex package (v0.3.0)

If the output is first converted with tibble::as_tibble() it prints correctly in an IDE that supports UTF-8 (e.g., RStudio).

The skimr::skim() function (https://github.com/ropensci/skimr) implements some similar methods from the pillar package to also print its histograms on Windows in compatible IDEs.

Do you think you could either implement a similar print method for precis objects to render correctly on Windows or at least provide an argument to suppress the histograms entirely?

@rmcelreath
Copy link
Owner

Try hist=FALSE.

@alessandro-gentilini
Copy link

@bwiernik I have similar problem with rmarkdown::render, and I am not in Windows :-). hist=FALSE solved my problem, yes the output is not so fancy but it's fine for me.

@drj2h3
Copy link

drj2h3 commented Feb 19, 2021

I have pasted this answer, which works well, from Issue #168. Props to Chris for an elegant solution! Worked for me on R Studio 1.1.456 using R with R x64 4.0.3:

chrisdissanayake commented on Apr 9, 2020
I had the same problem. I was going with ap53's suggestion, and the following thread gave me a clue to fix it.
https://stackoverflow.com/questions/44253848/skimr-cant-seem-to-produce-the-histograms

I type this line in rstudio source window.

Sys.setlocale(locale='Chinese')

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

4 participants