Closed AndreaPi closed 5 years ago
Did you change the font to something like DejaVu Sans?
https://github.com/ropenscilabs/skimr/blob/master/vignettes/Using_fonts.Rmd
In case your vignettes didn't build the information is there.
hi @elinw, thanks for the answers and I hope I'm not being annoying with my questions, but I really like skimr
and I use it a lot, which in turns generates many questions 😃
So, as suggested in your link, I opened skeleton.Rmd
. Btw, opening a new markdown file and selecting "From template" in RStudio didn't work: I couldn't see any skimr
menu in the template, so I had to navigate to C:\Users\...\Documents\R\win-library\3.4\skimr\markdown\templates\fonts_in_skimr\skeleton\skeleton.Rmd
and open the template directly.
skeleton.Rmd
suggests to execute the code
install.packages(c("extrafont"))
font_install("DejaVu Sans")
A library(extrafont)
command is missing (you may want to fix skeleton.Rmd
). I thus executed
install.packages(c("extrafont"))
library(extrafont)
font_install("DejaVu Sans")
I got the following error:
Package "DejaVu Sans" not installed. Would you like to install it from CRAN? [y/n] y
Attempting to install "DejaVu Sans" from CRAN...
Installing package into ‘C:/Users/.../Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘DejaVu Sans’ is not available (for R version 3.4.3)
Error in font_install("DejaVu Sans") :
Package "DejaVu Sans" not successfully installed.
Can I try something else, or should I give up including histograms in R Markdown HTML report?
It's strange that you can't see it on the list, I'll see it; I can figure out why. It could be related to other issues with the inst folder.
Can you try this? extrafonts::fonttable()
and see what fonts are listed and try to install a different DejaVu variation if one is available? It's one of the basic fonts so I'm surprised it's not available. Some of the other fonts may also support building blocks.
Something fishy is going on on my system...
> extrafont::fonttable()
data frame with 0 columns and 0 rows
here is the current sessionInfo
:
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Italian_Italy.1252 LC_CTYPE=Italian_Italy.1252
[3] LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C
[5] LC_TIME=Italian_Italy.1252
attached base packages:
[1] tools stats graphics grDevices utils datasets methods base
other attached packages:
[1] extrafont_0.17 bindrcpp_0.2 dplyr_0.7.4 skimr_1.0.1
[5] fitdistrplus_1.0-9 MASS_7.3-47 dotwhisker_0.3.0 gtable_0.2.0
[9] gridExtra_2.3 OIsurv_0.2 KMsurv_0.1-5 flexsurv_1.1
[13] survival_2.41-3 visdat_0.1.0 magrittr_1.5 ggplot2_2.2.1
[17] readr_1.1.1 knitr_1.17 RevoUtils_10.0.7 RevoUtilsMath_10.0.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 mvtnorm_1.0-6 lattice_0.20-35 tidyr_0.7.2
[5] muhaz_1.2.6 rprojroot_1.2 assertthat_0.2.0 digest_0.6.12
[9] psych_1.7.8 R6_2.2.2 plyr_1.8.4 backports_1.1.1
[13] evaluate_0.10.1 ggstance_0.3 highr_0.6 rlang_0.1.2
[17] lazyeval_0.2.0 extrafontdb_1.0 Matrix_1.2-12 rmarkdown_1.8
[21] splines_3.4.3 stringr_1.2.0 foreign_0.8-69 pander_0.6.1
[25] munsell_0.4.3 broom_0.4.2 compiler_3.4.3 pkgconfig_2.0.1
[29] mnormt_1.5-5 htmltools_0.3.6 tidyselect_0.2.2 tibble_1.3.4
[33] quadprog_1.5-5 grid_3.4.3 Rttf2pt1_1.3.5 nlme_3.1-131
[37] scales_0.5.0 stringi_1.1.6 reshape2_1.4.2 deSolve_1.20
[41] RColorBrewer_1.1-2 glue_1.1.1 mstate_0.2.10 purrr_0.2.3
[45] hms_0.3 parallel_3.4.3 yaml_2.1.14 colorspace_1.3-2
[49] bindr_0.1
Try this extrafont::font_import()
I just did that on my non development system and it seemed to work.
hi @elinw, ok, some progress! Yay 😃 extrafont::font_import()
effectively imported dozens of fonts on my system. Apparently, though, DejaVu is not among them:
extrafont::font_import()
# skipping very long output
p <- extrafonts::fonttable()
grep("DejaVu", p$FontName)
# integer(0)
grep("Times", p$FontName)
# [1] 294 295 296 297
p$FontName[grep("Times", p$FontName)]
# [1] "TimesNewRomanPS-BoldItalicMT" "TimesNewRomanPS-BoldMT"
# [3] "TimesNewRomanPS-ItalicMT" "TimesNewRomanPSMT"
What should I do next?
Ok, I've read around on the Internet and I'm "strongly suspecting" that DejaVu
fonts don't exist on Windows. If you go to their download page, you'll see all sorts of Linux distributions but no Windows:
https://dejavu-fonts.github.io/Download.html
Also, here it says that they are available on Linux but neither on Windows or OS X. Can you suggest any other font to try? If it helps, I can post the full list of available list on Windows obtained with extrafonts::fonttable()
, though it's a 319 x 10 data frame
They definitely work on Mac. Sure post the list and let’s explore.
On Jan 31, 2018, at 1:42 PM, Andrea Panizza notifications@github.com wrote:
Ok, I've read around on the Internet and I'm "strongly suspecting" that DejaVu fonts don't exist on Windows. If you go to their download page, you'll see all sorts of Linux distributions but no Windows:
https://dejavu-fonts.github.io/Download.html https://dejavu-fonts.github.io/Download.html Also, here http://www.grputland.com/2012/09/three-font-stacks-to-match-dejavu.html it says that they are available on Linux but neither on Windows or OS X. Can you suggest any other font to try? If it helps, I can post the full list of available list on Windows obtained with extrafonts::fonttable() , though it's a 319 x 10 data frame
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ropenscilabs/skimr/issues/263#issuecomment-362029574, or mute the thread https://github.com/notifications/unsubscribe-auth/AAuEfcTh7wJbo_nHiNwE1tw1gmw8WJpVks5tQLQhgaJpZM4RspvJ.
I can't manage to copy the dataframe because it's too big, so I put it into a shared folder:
https://drive.google.com/file/d/0B8HxKpOURPQXQUNBR1ZJN20yZVNyRVZnclVfa1NxeVNYMEI4/view?usp=sharing
http://www.fileformat.info/info/unicode/block/block_elements/fontsupport.htm Is a list of some fonts that support block elements. For reference http://www.unicode.org/charts/PDF/U2580.pdf http://www.fileformat.info/info/unicode/block/block_elements/list.htm
This is an old list http://www.alanwood.net/unicode/block_elements.html however I have seen mention of NSimSun in other discussions. You may need to switch your locale to a multibyte language (Chinese, Japanese etc) and use one of those. You may also need to install a font directly.
I give up. I was able to install Deja Vu Sans on Windows 10, I changed my locale to Chinese simplified and even though something has indeed changed (I can see something, where histograms should be), the result is still bad. I guess histograms in R Markdown on Windows 10 were just not meant to be 😃
---
title: "test"
mainfont: DejaVu Sans
author: "`r Sys.Date()`"
date: '_reading time: ? minutes_'
subtitle: Anon
output:
html_document:
fig_caption: yes
keep_md: yes
font-family: Times New Roman
params:
output_dir: ../output
---
```{r setup, include=FALSE}
library(knitr)
library(skimr)
library(dplyr)
library(extrafont)
opts_chunk$set(warning = FALSE,
message = FALSE,
fig.align = "center",
fig.width = 7.25,
fig.height = 6)
Let's check we have indeed installed Deja Vu Sans
fonts <- extrafont::fonttable()
any(grepl("Deja", fonts$FontName))
What about locale? Do we have a real UTF-8 locale, such as Chinese?
sessionInfo()
kable(skim(mtcars))
Results: [HTML file](https://drive.google.com/open?id=0B8HxKpOURPQXSU05SEpUNzY4alVWQXFzaFRSM3R3N0s1RWdJ) and [an image showing only the histograms part](https://drive.google.com/open?id=0B8HxKpOURPQXd2dYQl9SS3VkZ045R3VvbXVWdm1RVVdDc2lr)
Shall I close the issue? I don't think it can be solved.
PS thanks a lot for your help and your patience in trying to figure this out with me!
No don't close we need to solve this, I think now that Microsoft is invested in R we might want to actually ask them directly. Of course one possibility is to use a non free font like that recommended with th pillar package https://www.fsd.it/shop/fonts/pragmatapro/ but I think we really want a free solution. @michaelquinn32 any thoughts on this?
Arial is actually supposed to support Block Elements. http://www.alanwood.net/unicode/fonts.html You could try installing that into R. You can install fonts outside of the list from extrafonts.
Ok, I'll leave it open. After using extrafont::font_import()
I think I already have Arial installed in my R:
fonts <- extrafont::fonttable()
any(grepl("Arial", fonts$FontName))
# [1] TRUE
This means I have Arial installed in R, right?
yes!
Did Arial give you histograms?
Arial gave me the same results as DejaVu: here is the .Rmd file. Could you please double check that the YAML header is correct?
---
title: "test"
mainfont: ArialMT
author: "`r Sys.Date()`"
date: '_reading time: ? minutes_'
subtitle: Anon
output:
html_document:
fig_caption: yes
keep_md: yes
font-family: Arial
params:
output_dir: ../output
---
```{r setup, include=FALSE}
library(knitr)
library(skimr)
library(dplyr)
library(extrafont)
opts_chunk$set(warning = FALSE,
message = FALSE,
fig.align = "center",
fig.width = 7.25,
fig.height = 6)
Let's check we have indeed installed Deja Vu Sans
fonts <- extrafont::fonttable()
any(grepl("Deja", fonts$FontName))
What about locale? Do we have a real UTF-8 locale, such as Chinese?
sessionInfo()
kable(skim(mtcars))
skim(mtcars)
The result is the same gibberish, in place of the histograms, as in the case of DejaVu. I'm still using a Chinese locale.
The gibberish is characters not<U2xxx>
representations right? And you are getting characters no blank space (which is what I get sometimes). I'll see if I can find a Windows machine to access and let you know what I learn.
@elinw my problem is that from where I'm now, it's very complicated for me to upload images on a shared drive. Let's see if I can incorporate them:
Great! It works! So here is also the header of the report (the one with the sanity checks, so you can see that my locale is Chinese):
And finally another test where I tried to print skim(mtcars)
instead than kable(skim(mtcars))
:
Does this help? I can't seem to upload the HTML file from here. If you want to see that too, I can share it tomorrow. Or I can send you a mail!
This is really helpful, don't worry about the HTML unless you see something really interesting in it. You could always push that to RPubs if you wanted.
Here is the HTML report, let me know if it helped: http://rpubs.com/AndreaPi/356641
Hi @elinw! If there's anyhthing else I could help you with about this issue, let me know. I can share directly the HTML source, for example, if you want to check whether the fonts were loaded or not. I might also help with a bit of R coding, even though I've never loaded a package in CRAN, thus I don't think I could make a good PR.
Just letting you know we are still thinking about how to deal with this.
So sadly I am going to close this because the real issue is Microsoft's and the R core. We continue to try to come up with workarounds but I don't think there is a real solution possible at this point unless someone can fix how this works in the very deep parts of R and really C.
Hi, all,
with the new
skimr
version (1.0.1), I'm able to show histograms in the RStudio console under Windows, but I cannot show them in the HTML output of an R Markdown document. As perskimr
vignette recommendation, I'm usingkable
with a chunk option ofresults='asis'
. Reproducible example:test
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)
Matrix products: default
locale:
[1] LC_COLLATE=Italian_Italy.1252 LC_CTYPE=Italian_Italy.1252
[3] LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C
[5] LC_TIME=Italian_Italy.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] bindrcpp_0.2 dplyr_0.7.4 skimr_1.0.1
[4] knitr_1.17 RevoUtils_10.0.7 RevoUtilsMath_10.0.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 bindr_0.1 magrittr_1.5 tidyselect_0.2.2
[5] R6_2.2.2 rlang_0.1.2 highr_0.6 stringr_1.2.0
[9] tools_3.4.3 htmltools_0.3.6 yaml_2.1.14 rprojroot_1.2
[13] digest_0.6.12 assertthat_0.2.0 tibble_1.3.4 tidyr_0.7.2
[17] purrr_0.2.3 glue_1.1.1 evaluate_0.10.1 rmarkdown_1.8
[21] stringi_1.1.6 compiler_3.4.3 pander_0.6.1 backports_1.1.1
[25] pkgconfig_2.0.1