R doesn't allow me to define the number of columns I want my header to spawn

44 views Asked by At

I made a R-script and build several html tables with kablExtra. I made 4 tables. I forgot to make a header for the 3th. So I tried to make a header for the third with this code:

#### Set GLOBAL options ####
options(knitr.table.format = "html")

# make headers
main_icc_title <- c("Table 3: Intraclass Correlation coefficients between AVA 3.2"^"\u00AE"*" and CytoCamTools "^"\u00AE"*"." = 3)
main_icc_title_spec <- c(0,3)
    
  # Build the html table
    table_3 <- main_icc_table %>%
      kbl(col.names = c("Variable", "ICC [95% CI]", "Agreement"), align = "lll", row.names = FALSE) %>%
      kable_styling("striped") %>%
      column_spec(1, bold = TRUE, width = "10em") %>%
      column_spec(2, width = "10em") %>%
      column_spec(3, width = "10em") %>%
      kable_paper("hover", full_widt = F, position = "center") %>%
      add_header_above(main_icc_title, main_icc_title_spec) %>%
      footnote(general_title = "",  general = "Intraclass Correlations Coefficients were calculated for each variable using a two-way mixed effects model for single rater and absolute agreement. Confidence intervals and interpretation of agreement are given for each variable. ICC: intraclass correlation coeficient, CI: confidence interval.")
    
  

But suddenly I got the error:

main_icc_title <- c("Table 3: Intraclass Correlation coefficients between AVA 3.2"^"\u00AE"*" and CytoCamTools"^"\u00AE"*"." = 3)
Error: unexpected '=' in "     main_icc_title <- c("Table 3: Intraclass Correlation coefficients between AVA 3.2"^"\u00AE"*" and CytoCamTools"^"\u00AE"*"." ="

I removed the =, but then ofcourse it doesn't spawn the right amount of columns. But suddenly R also stopped accepting ^"\u00AE"*.

Error in "Table 3: Intraclass Correlation coefficients between AVA 3.2"^"®" : 
  non-numeric argument to binary operator

The weirdest thing is. Now table 4, which was working perfectly fine, gets the same errors. While Table 1 and 2 work perfectly fine...

Thanks a lot for your help!

0

There are 0 answers