I want to highlight certain cells in a table.
For example, highlight all cells where total_n_obs > 5000
.
I have seen solutions from ~2 years ago (which use CSS or pander) but have not been able to implement them.
Is there a way to code this directly into an RMarkdown script?
Thanks a lot, I really appreciate any help/ideas!
To highlight text change the background-color style of total_n_obs
column, as shown in the example below. (I have created a new column using the plyr::summarise command)
library(plyr)
df2 <- adply(df,1,
summarise, total_n_obs_t = ifelse(total_n_obs >= 5000,
paste('<div style="background-color: yellow; text-align: right;">',total_n_obs,'</div>',sep=""),
paste('<div style="font-weight: bold; text-align: right;">',total_n_obs,'</div>',sep="")
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.