How do I format an R table in an R Jupyter notebook?

Viewed 3986

Suppose I am using a Jupyter notebook with an R kernel, and I want to format a table so that any row with p_value < 0.01 is bolded. How?

I looked around a bit, and I can find R styling not in Jupyter, Jupyter styling not in R, and so forth, but not what I want.

1 Answers

How about this approach?

library(knitr)
library(kableExtra)
library(IRdisplay)

mtcars %>%
  kable("html") %>%
  row_spec(which(mtcars$mpg > 20), bold = T, color = "red") %>%
  as.character() %>%
  display_html()

enter image description here

Related