Search code examples
rlatexr-markdownkableextra

! extra alignment tab error in KableExtra


I am receiving an error

! Extra alignment tab has been changed to \cr. \endtemplate

In table 4, where the problem is occurring, is written in the exact same way as the other tables; the other table knit just fine. When I run the chunk for table 4 it does produce the latex code, but won't knit. Since this is an Rmd file and it posts funny. here are links to both my code and my data.

code

Data

I am unsure what the error is saying. I have tried adding alignment and taking away. forexample,

kable(licen_area,
      "latex",
      booktabs=T,
      align="lcc",
      col.names=linebreak(c("Licensure\nArea","Count", "\\%"),align="c"),
      row.names=F,
      escape=F)

versus

kable(licen_area,
      "latex",
      booktabs=T,
      align="lccc",
      col.names=linebreak(c("Licensure\nArea","Count", "\\%"),align="c"),
      row.names=F, 
      escape=F)

I have set up a randomly generated data set using:

grad_YR <- sample(c("2012-13", "2014-15","2015-16","2016-17","2017-18"), 150, prob=c(".02",".03",".05",".4",".5"), replace=T)
Degree <- sample(c("BA/BS","Master's"),150,prob=c(".75",".25"),replace=T)
licen_Area1 <- sample(c("Art","Dance","Early Childhood","Elementary","Middle","Secordary"),150,prob=c(".02",".01",".35",".35",".13",".14"),replace=T)
sam_dat <- as.data.frame(cbind(Univ,grad_YR,Degree,licen_Area1))```

Table 4 ran knit with no issues. 

Solution

  • Kable doesn't like it when there are special characters in the data. In the linked that there are several &'s. I removed those and it worked just fine!