Emboldens rows matching an expression, with optionally selected columns. For use with knitr::kable().

knitr_bold_row(x, ..., cols = NULL, format = c("markdown", "html", "latex"))

Arguments

x

A data frame

...

The filter expressions

cols

Columns that should be emphasized, default NULL or all columns

format

One of "markdown", "html", or "latex"

Examples

x <- dplyr::starwars[1:4, 1:5] knitr_bold_row(x, height < 100)
#> # A tibble: 4 x 5 #> name height mass hair_color skin_color #> <chr> <chr> <chr> <chr> <chr> #> 1 Luke Skywalker 172 77 blond fair #> 2 C-3PO 167 75 <NA> gold #> 3 **R2-D2** **96** **32** <NA> **white, blue** #> 4 Darth Vader 202 136 none white
knitr_bold_row(x, mass <= 75, height <= 170, cols = c("name", "height"), format = "html")
#> # A tibble: 4 x 5 #> name height mass hair_color skin_color #> <chr> <chr> <dbl> <chr> <chr> #> 1 Luke Skywalker 172 77 blond fair #> 2 <strong>C-3PO</strong> <strong>167</strong> 75 <NA> gold #> 3 <strong>R2-D2</strong> <strong> 96</strong> 32 <NA> white, blue #> 4 Darth Vader 202 136 none white
x %>% knitr_bold_row(height > 170, cols = "hair_color") %>% knitr::kable()
#> #> #> |name | height| mass|hair_color |skin_color | #> |:--------------|------:|----:|:----------|:-----------| #> |Luke Skywalker | 172| 77|**blond** |fair | #> |C-3PO | 167| 75|NA |gold | #> |R2-D2 | 96| 32|NA |white, blue | #> |Darth Vader | 202| 136|**none** |white |