knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
rainbowrite::lol_hooks()
For the most basic use, with defaults, just replace cat
, message
or print
with calls to lolcat
, lolmessage
or lolprint
, respectively:
x <- runif(30) print(x)
becomes
rainbowrite::lolprint(x)
containing the same great data, but now with much more unicorn flavour.
If this is not enough control, you can interact directly with the rainbowrite::lol
object. This has options that can tune the colour cycling. For example, to cycle colours faster than the default, and with a flatter angle (shifting so that rows cycle faster then columns)
lol_faster <- rainbowrite::lol$new(rate = 0.1, angle = pi / 10)
This can be passed into rainbowrite::lolprint
and friends:
rainbowrite::lolprint(x, lol = lol_faster)
Or can be set as the default
lol_faster$set_as_default() rainbowrite::lolprint(x)
Some packages may not use lolcat, but we may want them to be more colourful.
For example, the cowsay
package is great:
cowsay::say("I wish I was more colourful", "cow")
but could do with more colours. Use rainbowrite::lolify
to create a copy of the target function where some of cat
, message
or print
are replaced by their lol versions
lolcow <- rainbowrite::lolify(cowsay::say)
and use it as
lolcow("These colours mooove me!", "cow", type = "print")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.