I have a table that I'm trying to put 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, producing the following error:
Error in stri_replace_first_regex(string, pattern, fix_replacement(replacement), : Trying to access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Calls: ... row_spec_latex -> str_replace -> stri_replace_first_regex ->. Call
If I remove the row_spec
portion, it works. If I remove the dollar signs, it works. If I change the row to be row 0 instead of row 1, it works. But I cannot change the colors of rows with dollar signs in them. I know that $ is a reserved character in latex, but as an experiment I looked up all the reserved characters and tried it with them instead of the dollar sign and everything worked. Dollar sign is the only one that is giving me trouble.
Is there some way to make this work or am I doomed to having a stark white table?