knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(ggplot2) library(emphatic)
library(ggplot2) library(emphatic)
test_df <- head(mtcars, 10)
The methods for selecting rows works similar to tidyselect
used by
dplyr. This is a bespoke implementation of these selections, and may not work
exactly the same:
| selector | description | example
|---------:|------------:|--------------:|
|all()
|all rows | all()
|
|starts_with()
|rownames start with the given text | starts_with("day")
|
|ends_with()
|rownames end with the given text |ends_width("2024")
|
|everything()
|all rows (the default behaviour) |everything()
|
|all_of()
| all of the specified rownames |all_of(c('mpg', 'wt'))
|
|any_of()
| any of the specified rownames | any_of(c('mpg', 'wt'))
|
|matches()
|regular expression matches against rownames |matches("day0\\d+")
|
|contains()
|rowname contains the given text |contains("value")
|
|row_number()
|the number of row | row_number() == 3
|
|all()
|select everything |all()
|
|n()
| returns integer specifying number of rows |rows = c(n(), n() / 2)
will select last row and half-way|
test_df |> hl('skyblue')
test_df |> hl('skyblue', rows = NULL)
test_df |> hl('skyblue', rows = all())
test_df |> hl('skyblue', rows = 2:5)
test_df |> hl('skyblue', rows = c('Mazda RX4', 'Datsun 710'))
test_df |> hl('skyblue', rows = Valiant)
test_df |> hl('skyblue', rows = mpg > 22)
n()
and row_number()
test_df |> hl('skyblue', rows = row_number() > n()/2)
tidyselect
test_df |> hl('skyblue', rows = contains('hornet'))
test_df |> hl('skyblue', rows = starts_with('m'))
test_df |> hl('skyblue', rows = any_of(c('Valiant', 'Herbie', 'Datsun 710')))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.