cowsay makes it easy to print messages, warnings, or character strings with various animals and other creatures.

Installation

Stable version from CRAN

install.packages("cowsay")

or dev version from GitHub

install.packages("devtools")
devtools::install_github("sckott/cowsay")
library("cowsay")

The animals

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 41 animals.

The names of the animals:

sort(names(animals))
#>  [1] "ant"          "anxiouscat"   "bat"          "bat2"        
#>  [5] "behindcat"    "bigcat"       "buffalo"      "cat"         
#>  [9] "chicken"      "clippy"       "cow"          "daemon"      
#> [13] "duck"         "duckling"     "egret"        "endlesshorse"
#> [17] "facecat"      "fish"         "frog"         "ghost"       
#> [21] "grumpycat"    "hypnotoad"    "longcat"      "longtailcat" 
#> [25] "monkey"       "mushroom"     "owl"          "pig"         
#> [29] "poop"         "pumpkin"      "rabbit"       "shark"       
#> [33] "shortcat"     "signbunny"    "smallcat"     "snowman"     
#> [37] "spider"       "stretchycat"  "trilobite"    "turkey"      
#> [41] "yoda"

For example, access the cow

cow <- animals[['cow']]
cat(cow)
#> 
#>  ----- 
#> %s 
#>  ------ 
#>     \   ^__^ 
#>      \  (oo)\ ________ 
#>         (__)\         )\ /\ 
#>              ||------w|
#>              ||      ||

Say something

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 
#>  --------------
#>     \
#>       \
#>         \
#>             |\___/|
#>           ==) ^Y^ (==
#>             \  ^  /
#>              )=*=(
#>             /     \
#>             |     |
#>            /| | | |\
#>            \| | |_|/\
#>       jgs  //_// ___/
#>                \_)
#> 

There’s the special time, that will print out the time

say('time')
#> 
#>  -------------- 
#> 2018-05-15 10:47:57 
#>  --------------
#>     \
#>       \
#>         \
#>             |\___/|
#>           ==) ^Y^ (==
#>             \  ^  /
#>              )=*=(
#>             /     \
#>             |     |
#>            /| | | |\
#>            \| | |_|/\
#>       jgs  //_// ___/
#>                \_)
#> 

It’s how you say it

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 ----- \nhello world \n ------ \n    \\   ^__^ \n     \\  (oo)\\ ________ \n        (__)\\         )\\ /\\ \n             ||------w|\n             ||      ||"