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

loading kableExtra seems to break the skim html output #637

Open
ArthurAndrews opened this issue Feb 18, 2021 · 14 comments
Open

loading kableExtra seems to break the skim html output #637

ArthurAndrews opened this issue Feb 18, 2021 · 14 comments

Comments

@ArthurAndrews
Copy link

ArthurAndrews commented Feb 18, 2021

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
---
title: "skim test"
output: html_document
---

```{r}
library(skimr)
library(knitr)
library(kableExtra) # this messes up the skim table
```

```{r}
skim(iris)
```

This one works
---
title: "skim test"
output: html_document
---

```{r}
library(skimr)
library(knitr)
```

```{r}
skim(iris)
```
@michaelquinn32
Copy link
Collaborator

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!

@elinw
Copy link
Collaborator

elinw commented Feb 22, 2021

Yes I definitely see some formatting issues in html, PDF and Word.

@elinw
Copy link
Collaborator

elinw commented Feb 22, 2021

kableExtra does have its own exported kable() function. So that could be causing a clash.

@ArthurAndrews
Copy link
Author

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)

@ArthurAndrews
Copy link
Author

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.

@elinw
Copy link
Collaborator

elinw commented Feb 23, 2021

You are on Windows, and we explain in the documentation that R on Windows at this point does not support unicode.

@elinw
Copy link
Collaborator

elinw commented Feb 25, 2021

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?

@elinw elinw pinned this issue Feb 27, 2021
@elinw
Copy link
Collaborator

elinw commented Mar 24, 2021

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?

@ArthurAndrews
Copy link
Author

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.

@elinw
Copy link
Collaborator

elinw commented Mar 28, 2021

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.

@elinw
Copy link
Collaborator

elinw commented Jan 1, 2022

@haozhu233 Were you ever able to address this issue in kableExtra?

@haozhu233
Copy link
Collaborator

@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.

@michaelofrancis
Copy link

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.

@michaelquinn32
Copy link
Collaborator

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!

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

5 participants