Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 311
dfrankow Avatar asked Sep 14 '25 11:09

dfrankow


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

like image 134
Hao Avatar answered Sep 17 '25 01:09

Hao