cowsay
makes it easy to print messages, warnings, or
character strings with various animals and other creatures.
Stable version from CRAN
install.packages("cowsay")
or dev version from GitHub
# install.packages("pak")
pak::pak("sckott/cowsay")
library(cowsay)
The animals, and other ascii creatures, are all in a single named character vector that is exported from the package. Thus, you can access each animal yourself, and do whatever you want with it.
As of this writing, there are 56 animals.
The names of the animals:
sort(names(animals))
#> [1] "alligator" "ant" "anxiouscat" "bat" "bat2"
#> [6] "behindcat" "bigcat" "buffalo" "cat" "chicken"
#> [11] "chuck" "clippy" "cow" "cow_borg" "cow_dead"
#> [16] "cow_greedy" "cow_sleepy" "cow_tired" "cow_wired" "cow_young"
#> [21] "daemon" "duck" "duckling" "egret" "endlesshorse"
#> [26] "facecat" "fish" "frog" "ghost" "goldfish"
#> [31] "grumpycat" "hypnotoad" "longcat" "longtailcat" "monkey"
#> [36] "mushroom" "owl" "pig" "poop" "pumpkin"
#> [41] "rabbit" "shark" "shortcat" "signbunny" "smallcat"
#> [46] "snowman" "spider" "squirrel" "squirrel2" "stegosaurus"
#> [51] "stretchycat" "trilobite" "turkey" "whale" "wolf"
#> [56] "yoda"
For example, access the cow
cow <- animals[["cow"]]
cat(cow)
#>
#> ^__^
#> (oo)\ ________
#> (__)\ )\ /\
#> ||------w|
#> || ||
We expose the function say()
in this package, which you
can use to envoke any animal in the package, and make it say whatever
you want. Some examples:
say("why did the chicken cross the road", "chicken")
#>
#> ------------------------------------
#> < why did the chicken cross the road >
#> ------------------------------------
#> \
#> \
#> _
#> _/ }
#> `>' \
#> `| \
#> | /'-. .-.
#> \' ';`--' .'
#> \'. `'-./
#> '.`-..-;`
#> `;-..'
#> _| _|
#> /` /` [nosig]
#>
say("boo!", "ghost")
#>
#> ------
#> < boo! >
#> ------
#> \
#> \
#>
#> .-.
#> (o o)
#> | O \
#> \ \
#> `~~~' [nosig]
#>
say("nope, don't do that", type = "warning")
#> Warning in say("nope, don't do that", type = "warning"):
#> ---------------------
#> < nope, don't do that >
#> ---------------------
#> \
#> \
#>
#> ^__^
#> (oo)\ ________
#> (__)\ )\ /\
#> ||------w|
#> || ||
There’s the special time
, that will print out the
time
say("time")
#>
#> ----------------------------
#> < 2024-12-05 08:25:09.044271 >
#> ----------------------------
#> \
#> \
#>
#> ^__^
#> (oo)\ ________
#> (__)\ )\ /\
#> ||------w|
#> || ||
You can use say()
and give back a string, message, or
warning
Message
say("hello world", by = "cow")
#>
#> -------------
#> < hello world >
#> -------------
#> \
#> \
#>
#> ^__^
#> (oo)\ ________
#> (__)\ )\ /\
#> ||------w|
#> || ||
Warning
say("hello world", by = "cow", type = "warning")
#> Warning in say("hello world", by = "cow", type = "warning"):
#> -------------
#> < hello world >
#> -------------
#> \
#> \
#>
#> ^__^
#> (oo)\ ________
#> (__)\ )\ /\
#> ||------w|
#> || ||
String
say("hello world", by = "cow", type = "string")
#> [1] "\n ------------- \n< hello world >\n ------------- \n \\\n \\\n\n ^__^ \n (oo)\\ ________ \n (__)\\ )\\ /\\ \n ||------w|\n || ||"