Open ArthurAndrews opened 3 years ago
Hi Arthur!
I'm wording if if we somehow have a namespace clash. Can you please install the reprex package and call the following:
reprex::reprex({
library(skimr)
library(knitr)
library(kableExtra)
})
Otherwise, could you let me know what else you mean by doesn't print correctly"? Is it a unicode character issue or something else?
Thanks!
Yes I definitely see some formatting issues in html, PDF and Word.
kableExtra does have its own exported kable()
function. So that could be causing a clash.
reprex::reprex({ library(skimr) library(knitr) library(kableExtra) })
Here's my reprex output. Doesn't seem to throw any errors. I don't get any warnings, even about function conflicts.
library(skimr)
library(knitr)
library(kableExtra)
Created on 2021-02-22 by the reprex package (v1.0.0)
Otherwise, could you let me know what else you mean by doesn't print correctly"? Is it a unicode character issue or something else?
No problem. Seems to be a combination of unicode issue and formatting. Unicode issues for the histograms, where I see output like "U+2586". Formatting issues where the fonts seem too large and the column titles overlap and the column entries don't line up nicely.
You are on Windows, and we explain in the documentation that R on Windows at this point does not support unicode.
I really feel this is a problem of kableExtra, but still we may need to fix. It also impacts printing on the console. I checked our code and any time we use the knitr() function we namespace it, but it's probably that there is another namespace issue buried inside knitr. Is there a way we can explicitly unload kableExtra?
So the explanation is the kableExtra changes the default to html. We could possibly try to change the default back but I guess the question is why use kableExtra when using skimr?
So the explanation is the kableExtra changes the default to html. We could possibly try to change the default back but I guess the question is why use kableExtra when using skimr?
Any time a person wants to display html tables and data frame summary statistics in the same markdown document, they might use the two packages. They have different purposes.
Right now, I think until kableExtra comes up with a less intrusive way of doing things, you would need to change the default before and after skimming. I have no idea if that will actually work. I'm really surprised that CRAN allowed this.
@haozhu233 Were you ever able to address this issue in kableExtra?
@elinw Sure, sorry for the delay. There is an option in kableExtra that controls this behavior.
options(kableExtra.auto_format = FALSE)
If you turn the auto_format
option off, kableExtra will no longer automatically set the global environment for knitr::kable
. How about adding the above option to zzz.R in skimr? It will change the default behavior of kableExtra but I think that's the best thing we can do at this moment.
Is it possible to put a note about this in the skimr vignette? I'm new to skimr and just spent a couple hours trying to fix this before coming across this solution in the post. Might save others some time in the future.
Really sorry for the inconvenience!
I'd be happy to accept a PR to add this. If you're interested, please check out the contributing guide.
Thanks!
First of all, thanks for the great package!
I haven't been able to use skimr and kableExtra in the same Markdown document. If I have a library(kableExtra) statement, the skim table doesn't print correctly in the knit document.
I was able to create these two simple documents to illustrate the problem. I'm on Windows 10 and using skimr 2.1.2.
This one has the issue
This one works