knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(ggplot2) library(emphatic)
library(ggplot2) library(emphatic)
test_df <- head(mtcars, 10)
The methods for selecting columns 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
|---------:|------------:|--------------:|
|starts_with()
|names of columns start with the given text | starts_with("day")
|
|ends_with()
|names of columns end with the given text |ends_width("2024")
|
|everything()
|all columns (the default behaviour) |everything()
|
|all_of()
| all of the named columns |all_of(c('mpg', 'wt'))
|
|any_of()
| any of the named columns | any_of(c('mpg', 'wt'))
|
|matches()
|regular expression matches against column names |matches("day0\\d+")
|
|contains()
|name contains the given text |contains("value")
|
|col_number()
|the number of column | col_number() == 3
|
|all()
|select everything |all()
|
|n()
| returns integer specifying number of cols |cols = n()
will select the last column |
test_df |> hl('skyblue')
test_df |> hl('skyblue', cols = NULL)
test_df |> hl('skyblue', cols = all())
test_df |> hl('skyblue', cols = 2:5)
test_df |> hl('skyblue', cols = c('mpg', 'gear'))
test_df |> hl('skyblue', cols = c(drat, am))
test_df |> hl('skyblue', cols = drat:am)
col_number()
test_df |> hl('skyblue', cols = col_number() < 4)
tidyselect
test_df |> hl('skyblue', cols = contains('a'))
test_df |> hl('skyblue', cols = ends_with('t'))
test_df |> hl('skyblue', cols = any_of(c('mpg', 'wt', 'age')))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.