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

R Code 4.9 histogram fails #168

Closed
kschulzke opened this issue Apr 7, 2019 · 7 comments
Closed

R Code 4.9 histogram fails #168

kschulzke opened this issue Apr 7, 2019 · 7 comments

Comments

@kschulzke
Copy link

When I run precis(d) (with R 3.5.3 and R Studio Version 1.1.463), the table prints in the console but the histogram does not render in the plot window. Rather, in the console, I get the text output shown below.

library(rethinking)
data(Howell1)
d <- Howell1
precis(d)
'data.frame': 544 obs. of 4 variables:
mean sd 5.5% 94.5%
height 138.26 27.60 81.11 165.74
weight 35.61 14.72 9.36 54.50
age 29.34 20.75 1.00 66.13
male 0.47 0.50 0.00 1.00

histogram
height <U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2582><U+2581><U+2587><U+2587><U+2585><U+2581>
weight <U+2581><U+2582><U+2583><U+2582><U+2582><U+2582><U+2582><U+2585><U+2587><U+2587><U+2583><U+2582><U+2581>
age <U+2587><U+2585><U+2585><U+2583><U+2585><U+2582><U+2582><U+2581><U+2581>
male <U+2587><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2587>

@rmcelreath
Copy link
Owner

This has something to do with your console not having unicode fonts, I think. It's not related to my package specifically, at least.

@troelsring
Copy link

I have the same problem as jedijd reported in RStudio with brandnew installations in Windows10. - RStudio is said to support unicode and if I try to "reopen with encoding" the code of
data(Boxes)
precis(Boxes) using UTF-8 this is what I get

'data.frame': 629 obs. of 5 variables:
mean sd 5.5% 94.5%
y 2.12 0.73 1 3
gender 1.51 0.50 1 2
age 8.03 2.50 5 13
majority_first 0.48 0.50 0 1
culture 3.75 1.96 1 8
histogram
y <U+2583><U+2581><U+2581><U+2581><U+2587><U+2581><U+2581><U+2581><U+2581><U+2585>
gender <U+2587><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2587>
age <U+2587><U+2583><U+2585><U+2583><U+2583><U+2583><U+2582><U+2582><U+2582><U+2581>
majority_first <U+2587><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2581><U+2587>
culture <U+2583><U+2582><U+2581><U+2587><U+2581><U+2582><U+2581><U+2582><U+2581><U+2582><U+2581><U+2581><U+2581><U+2581>

BW
Troels

@ap53
Copy link

ap53 commented Nov 10, 2019

Thank you for making your work open source! I am enjoying learning from your book.

I have the same issue, also on a new windows 10 machine.
Just to check, I have installed package skimr which also plots histograms with unicode blocks, and it works fine...
Antoine

@facorread
Copy link

This problem is part of a long-standing bug in base R. See these issues: 1 2. One workaround is to save the precis output into a variable, remove the histogram, and then print it. Another workaround is to plot the precis output instead of printing. A workaround for precis(model) is to print/plot a coeftab(model).

@ap53
Copy link

ap53 commented Nov 11, 2019 via email

@chrisdissanayake
Copy link

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')

image

@jtelleriar
Copy link

Yes, the chinese thing worked to me XD

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

7 participants