I have a table that I am trying to insert into a PDF with R Markdown.
dt <- c(name = c("a", "b", "c"),
money = c("$1", "$10", "$100")
dt %>%
kable(format = "latex") %>%
row_spec(1, background = "blue")
The above code does not work, creating the following error:
Error in stri_replace_first_regex (row, pattern, fix_replacement (replacement) :: attempt to access an index that has no borders. (U_INDEX_OUTOFBOUNDS_ERROR) Calls: ... row_spec_latex → str_replace → stri_replace_first_regex →.
If I remove the part row_spec, it will work. If I remove the dollar signs, it will work. If I changed line to line 0 instead of line 1, it will work. But I can’t change the colors of the lines with dollar signs in them. I know that $ is a reserved character in latex, but as an experiment, I looked for all the reserved characters and tried to use them instead of the dollar sign, and it worked. The dollar sign is the only one that causes me problems.
Is there any way to make this work, or am I doomed to have a white white table?
source
share