Error in KableExtra when adding percentage signs in cells

Viewed 229

I have the following table in an RMarkdown file using the kableExtra package

library(kableExtra)
library(tidyverse)

type <- c('Portfolio','Benchmark','Excess')
oct <- c("0.121",'0.108','1.32')
nov <- c('0.29','0.265','2.44')
dec <- c('0.315', '0.276','3.9')
q4 <- c('0.727','0.65','7.69')


data.frame(type,oct,nov,dec,q4) %>% 
  kable(format='latex',caption="Portfolio Income and Market Value, Q4 2020 \\label{Table2}",
        col.names = c('',"Oct-20*","Nov-20",'Dec-20',"Q4-20"), booktabs = T, escape = FALSE) %>% 
  kable_styling(latex_options = c("HOLD_position"), font_size = 7) %>% 
  row_spec(0,bold=T,color = 'white', background = '#7c3042') %>% 
  row_spec(3,bold=T) %>% 
  column_spec(1:4, width = '1.5cm') %>% 
  footnote(general = "*Return earned over the last 10 days of October only.")

Works fine, but when I try to add a percentage sign (%) to each of the observations in my dataframe I get the following error when I try to knit my document

! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

Is there a way to add percentage labels to selected cells within my dataframe? TIA!

0 Answers
Related