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

Error with kableExtra::column_spec() might involve xml2 #328

Closed
eipi10 opened this issue Dec 23, 2020 · 2 comments
Closed

Error with kableExtra::column_spec() might involve xml2 #328

eipi10 opened this issue Dec 23, 2020 · 2 comments
Labels
reprex needs a minimal reproducible example

Comments

@eipi10
Copy link

eipi10 commented Dec 23, 2020

A recent question on StackOverflow describes the following error:

library(tidyverse)
library(knitr)
library(kableExtra)

Summary <- mtcars %>% 
            group_by(cyl, gear, carb) %>% 
            summarise(count = n(), .groups = "keep") %>% 
            arrange(desc(cyl))

kable(Summary, caption = "mtcars Data Summary\n", align = c('l','l','c','c')) %>%
                  kable_styling(bootstrap_options = c("striped","hover"),full_width = FALSE, position = "left") %>% 
                  collapse_rows(columns = 1, valign = "top") %>% 
                  column_spec(1, width = "3cm") %>% 
                  column_spec(2, width = "3cm") %>% 
                  column_spec(3, width = "2cm") %>% 
                  column_spec(4, width = "2cm")

# Error in xml_children(x)[[search]] : subscript out of bounds

The code works as expected until the last column_spec call, which produces the error. There's also an unsolved kableExtra issue that seems to be similar to this and that may be related to the xml2 package.

I thought I would report these errors here in case this is a bug in the xml2 package. If not, do you have any ideas on what's going wrong and whether there might be a workaround?

@eipi10 eipi10 changed the title Error with kableExtra::column_spec() appears to be occurring in xml2 Error with kableExtra::column_spec() might involve xml2 Dec 23, 2020
@hadley
Copy link
Member

hadley commented Feb 28, 2022

Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you! If you've never heard of a reprex before, start by reading about the reprex package, including the advice further down the page. Please make sure your reprex is created with the reprex package as it gives nicely formatted output and avoids a number of common pitfalls.

@hadley hadley added the reprex needs a minimal reproducible example label Feb 28, 2022
@eipi10
Copy link
Author

eipi10 commented Mar 1, 2022

I think you can close this. The error occurred with the listed code back in December 2020 when I filed this issue. However, it no longer occurs with the current version of kableExtra.

@hadley hadley closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

2 participants