Wrap text in backticks

ticks(..., r = FALSE)

Arguments

...

Character. Text to go between backticks, and any other arguments to be passed to glue.

r

Logical. Add r at the beginning, for R Markdown?

Value

Character. String surrounded in backticks.

ticks is a wrapper for glue, so you can use curly bracket notation and multiple character strings just like with glue.

ticks is particularly useful for R Markdown, where you don"t want to use a backtick because it would end the inline code block.

Sometimes you want to actually show an inline R code block, as text (instead of evaluating it). For that we"ve included a handy shortcut for adding the initial r .

Examples

ticks("foobar")
#> `foobar`
ticks("foo", "bar")
#> `foobar`
word1 <- "foo" word2 <- "bar" ticks("{word1}{word2} = 'stupid'", r = TRUE)
#> Error in eval(parse(text = text, keep.source = FALSE), envir): object 'word1' not found
word3 <- "random" ticks( "c(", "{word1}{word2} = 'surprisingly', ", "{word3} = 'painless'", ")", r = TRUE )
#> Error in eval(parse(text = text, keep.source = FALSE), envir): object 'word1' not found