Quantcast
Channel: Active questions tagged kable - Stack Overflow
Viewing all articles
Browse latest Browse all 106

Why is kable() / column_spec() highlighting some but not all specified values?

$
0
0

Am using kable() to produce simple report. I want all final column values less than 15 to be highlighted:

question_results <- dplyr::data_frame ('\\#'=c(1:15), 'Pre-Test Avg.'=c(10, 60, 20, 30, 30, 20, 0, 30, 50, 0, 10, 30, 20, 40, 30), 'Post-Test Avg.'=c(87.5, 100, 100, 37.5, 75, 75, 87.5, 87.5, 62.5, 12.5, 87.5, 100, 62.5, 50, 100))question_results$'$\\Delta$'<- question_results$'Post-Test Avg.' - question_results$'Pre-Test Avg.'kable(question_results, align = "cccc", caption = "Question Data", format="latex", position = "h!", escape = FALSE) %>%  row_spec(0,bold=TRUE) %>%   column_spec(4, background = ifelse(question_results$'$\\Delta$'> 15, "white", "yellow")) %>%   kable_styling(latex_options = c("striped")) %>%footnote(general = c("$\\\\Delta$ denotes simple change in value: Post-Test Score minus Pre-Test Score."), escape = FALSE, footnote_as_chunk = TRUE, threeparttable = TRUE) 

Works great, except that the 12.5 on row 9 should also be highlighted. What am I missing??

Thanks in advance for any help.enter image description here


Viewing all articles
Browse latest Browse all 106

Trending Articles