项目作者: sckott

项目描述 :
cowsay w/ more animals, in R
高级语言: HTML
项目地址: git://github.com/sckott/cowsay.git
创建时间: 2013-10-11T00:09:58Z
项目社区:https://github.com/sckott/cowsay

开源协议:Other

下载


cowsay

cran checks
R-check
codecov
rstudio mirror downloads
cran version

What is this?

If you are familiar with cowsay on the cli, then you know what this is, but for R. If not, read below. Why? Why not?

History

cowsay was originally written by Tony Monroe, with the first code released in 1999. The version of cowsay you get via homebrew is a fork by Andrew Janke at https://cowsay.diamonds (code repo). The code for the original can be found at tnalpgge/rank-amateur-cowsay and the original website can be seen on the Wayback Machine. Both the original and version by Janke are both written in Perl. The cowsay you get with apt on Linux machines is the last version Monroe released in 2016 (v3.0.4 or possibly v3.0.3).

This R package has some additional features the orginal cowsay doesn’t have, but also lacks some features the original has. This package doesn’t yet support custom eyes and tongue for the cow or any other animals.

Contributors (alphabetical)

  • Amanda Dobbyn
  • Andreas Brandmaier
  • Andy Teucher
  • Carson Sievert
  • David Schoch
  • Franz-Sebastian Krah
  • Guangchuang Yu
  • Karl Broman
  • Kiyoko Gotanda
  • Lucy D’Agostino McGowan
  • Marion Louveaux
  • Noam Ross
  • Paolo Sonego
  • Philipp Boersch-Supan
  • Rich FitzJohn
  • Scott Chamberlain
  • Thomas Leeper
  • Tyler Rinker

That’s right, it takes 18 people to make cowsay - it’s that hard.

Contributing

See CONTRIBUTING.md

Where to find ASCII animal art

Sources to look in:

Permissions

In the ascii art mailing list https://groups.google.com/forum/#!forum/alt.ascii-art they say:

  1. As for posting other people's ASCII art,
  2. after a discussion in news:alt.ascii-art _ ___
  3. the following rules were agreed upon: #_~`--'__ `===-,
  4. 1. If an ASCII ART picture has initials `.`. `#.,//
  5. on it, leave them on when posting it ,_\_\ ## #\
  6. 2. If an ASCII ART picture doesn't have `__.__ `####\
  7. initials on it, mention that you ~~\ ,###'~
  8. didn't draw it when posting it. \##'
  9. 3. If somebody posts a picture without [nosig]
  10. initials and you have an original copy
  11. with initials on, feel free to re-post the original version.
  12. * The re-post ought not to be taken personally, as we all
  13. know that ASCII art often loses proper credits.
  14. Responses to the re-post are not necessary.
  15. One contributor, name of Krogg, suggested the following:
  16. 1.) Ultra polite:...ya make yer own ascii and use it.
  17. 2.) Very polite:...Ya contact the author and ask if ya
  18. can use it...
  19. 3.) polite:...Ya use it but you keep the Credits
  20. in there like they should be.
  21. 4.) rude:...Ya use it and strip credits.
  22. 5.) Very rude:...Ya use it and claim that it Is
  23. _Your_ very own creation...

So, let’s go with this rule: Let’s include found (on the web) ascii art in this pkg, include signature if there, and if no signature, put in a [nosig] (see above).

Quick watch start

Asciicast: https://asciinema.org/a/7745

Install

From CRAN

  1. # install.packages("pak")
  2. pak::pak("cowsay")

Dev version

  1. # install.packages("pak")
  2. pak::pak("sckott/cowsay")
  1. library("cowsay")

The animals

  1. sort(animals)
  2. #> [1] "alligator" "ant" "anxiouscat" "bat" "bat2"
  3. #> [6] "beavis" "behindcat" "bigcat" "blowfish" "buffalo"
  4. #> [11] "cat" "chicken" "chuck" "clippy" "cow"
  5. #> [16] "cow_borg" "cow_dead" "cow_greedy" "cow_sleepy" "cow_tired"
  6. #> [21] "cow_wired" "cow_young" "daemon" "dragon" "duck"
  7. #> [26] "duckling" "egret" "endlesshorse" "facecat" "fish"
  8. #> [31] "frog" "ghost" "goldfish" "grumpycat" "hypnotoad"
  9. #> [36] "longcat" "longtailcat" "monkey" "mushroom" "owl"
  10. #> [41] "pig" "poop" "pumpkin" "rabbit" "shark"
  11. #> [46] "shortcat" "signbunny" "smallcat" "snowman" "spider"
  12. #> [51] "squirrel" "squirrel2" "stegosaurus" "stretchycat" "trilobite"
  13. #> [56] "turkey" "whale" "wolf" "yoda"

Say Something

  1. say("time")
  2. #>
  3. #> ____________________________
  4. #> < 2025-03-28 15:30:56.460987 >
  5. #> ----------------------------
  6. #> \
  7. #> \
  8. #>
  9. #> ^__^
  10. #> (oo)\ ________
  11. #> (__)\ )\ /\
  12. #> ||------w|
  13. #> || ||
  1. say("ain't that some shit", "chicken")
  2. #>
  3. #> ______________________
  4. #> < ain't that some shit >
  5. #> ----------------------
  6. #> \
  7. #> \
  8. #> _
  9. #> _/ }
  10. #> `>' \
  11. #> `| \
  12. #> | /'-. .-.
  13. #> \' ';`--' .'
  14. #> \'. `'-./
  15. #> '.`-..-;`
  16. #> `;-..'
  17. #> _| _|
  18. #> /` /` [nosig]

Add some color:

  1. library(crayon)
  1. say("boo!", "ghost",
  2. what_color = "cyan", by_color = "saddlebrown"
  3. )


ghost

  1. say("I love hooo you are!", "owl",
  2. what_color = rgb(0, 1, 1), by_color = "#FF0000"
  3. )


owl

String styles together crayon-style:

  1. say(
  2. what = "rms", by = "rms",
  3. what_color = yellow$bgMagenta$bold,
  4. by_color = cyan$italic
  5. )


rms

This doesn’t preclude you from adding extra crayon colors to your what string directly - but the results are not super pretty:

  1. say(
  2. what = paste0("hello ", crayon::yellow("there "), crayon::underline("world")),
  3. by = "trilobite"
  4. )


trilobite

Vary type of output, default calls message()

  1. say("hell no!")
  2. #>
  3. #> __________
  4. #> < hell no! >
  5. #> ----------
  6. #> \
  7. #> \
  8. #>
  9. #> ^__^
  10. #> (oo)\ ________
  11. #> (__)\ )\ /\
  12. #> ||------w|
  13. #> || ||
  1. say("hell no!", type = "warning")
  2. #> Warning in say("hell no!", type = "warning"):
  3. #> __________
  4. #> < hell no! >
  5. #> ----------
  6. #> \
  7. #> \
  8. #>
  9. #> ^__^
  10. #> (oo)\ ________
  11. #> (__)\ )\ /\
  12. #> ||------w|
  13. #> || ||
  1. say("hell no!", type = "string")
  2. #> [1] "\n __________ \n< hell no! >\n ---------- \n \\\n \\\n\n ^__^ \n (oo)\\ ________ \n (__)\\ )\\ /\\ \n ||------w|\n || ||"

Catfacts!!!!

From the catfacts API at https://catfact.ninja

  1. say("catfact", "cat")
  2. #>
  3. #> ________________________________________________________
  4. #> < About 37% of American homes today have at least 1 cat. >
  5. #> --------------------------------------------------------
  6. #> \
  7. #> \
  8. #>
  9. #> |\___/|
  10. #> ==) ^Y^ (==
  11. #> \ ^ /
  12. #> )=*=(
  13. #> / \
  14. #> | |
  15. #> /| | | |\
  16. #> \| | |_|/\
  17. #> jgs //_// ___/
  18. #> \_)

Long cat

From the a Boing Boing tweet on 2014-05-10 “twitter.com/BoingBoing/status/465170473194512384” (post may be gone)

  1. say("it's caturday", "longcat")
  2. #>
  3. #> _______________
  4. #> < it's caturday >
  5. #> ---------------
  6. #> \
  7. #> \
  8. #>
  9. #> .ハ,,ハ
  10. #> ( ゚ω゚)
  11. #> |つ つ
  12. #> | |
  13. #> | |
  14. #> | |
  15. #> | |
  16. #> | |
  17. #> | |
  18. #> | |
  19. #> | |
  20. #> | |
  21. #> | |
  22. #> | |
  23. #> | |
  24. #> | |
  25. #> | |
  26. #> | |
  27. #> | |
  28. #> | |
  29. #> | |
  30. #> U " U
  31. #> [BoingBoing]

Grumpy cat

  1. say("NO!", by = "grumpycat")
  2. #>
  3. #> _____
  4. #> < NO! >
  5. #> -----
  6. #> \
  7. #> \
  8. #>
  9. #> ハ _ ハ
  10. #> ಠ X ಠ
  1. say("WOKE UP TODAY, IT WAS TERRIBLE", by = "grumpycat")
  2. #>
  3. #> ________________________________
  4. #> < WOKE UP TODAY, IT WAS TERRIBLE >
  5. #> --------------------------------
  6. #> \
  7. #> \
  8. #>
  9. #> ハ _ ハ
  10. #> ಠ X ಠ
  1. say("I HAD FUN ONCE, IT WAS AWFUL", by = "grumpycat")
  2. #>
  3. #> ______________________________
  4. #> < I HAD FUN ONCE, IT WAS AWFUL >
  5. #> ------------------------------
  6. #> \
  7. #> \
  8. #>
  9. #> ハ _ ハ
  10. #> ಠ X ಠ

Bunny Holding a sign

  1. say(by = "signbunny")
  2. #>
  3. #> ______________
  4. #> < Hello world! >
  5. #> --------------
  6. #> \
  7. #> \
  8. #>
  9. #> (\__/) ||
  10. #> (•ㅅ•) ||
  11. #> / づ
  12. #> [nosig]

Fish

  1. say(by = "fish")
  2. #>
  3. #> ______________
  4. #> < Hello world! >
  5. #> --------------
  6. #> \
  7. #> \
  8. #>
  9. #> ><((((º> ><((((º> ><((((º> ><((((º> ><((((º>
  10. #> Kiyoko Gotanda

R fortunes

  1. library(fortunes)
  2. say("fortune", "cat")
  3. #>
  4. #> ________________________________________________________
  5. #> / It is unusual for the actual data not to be available \
  6. #> | in real problems. Brian D. Ripley in reply to a |
  7. #> | question how to fit a distribution if not the data but |
  8. #> \ only their histogram is available R-help June 2006 /
  9. #> --------------------------------------------------------
  10. #> \
  11. #> \
  12. #>
  13. #> |\___/|
  14. #> ==) ^Y^ (==
  15. #> \ ^ /
  16. #> )=*=(
  17. #> / \
  18. #> | |
  19. #> /| | | |\
  20. #> \| | |_|/\
  21. #> jgs //_// ___/
  22. #> \_)

You can also pick a particular fortune by number or regex search - if the fortune parameter is not NULL you don’t have pass anything to the what parameter (the 1st parameter)

  1. say(fortune = 100)
  2. #>
  3. #> _________________________________________________________
  4. #> / I'm not sure I'd trust any computer recommendation from \
  5. #> | 1976, no matter how famous the authors are. Peter |
  6. #> | Dalgaard after Samuel Edward Kemp cited a |
  7. #> | recommendation about nonlinear least squares computer |
  8. #> \ programs from 'Box-Jenkins, 1976' R-help January 2005 /
  9. #> ---------------------------------------------------------
  10. #> \
  11. #> \
  12. #>
  13. #> ^__^
  14. #> (oo)\ ________
  15. #> (__)\ )\ /\
  16. #> ||------w|
  17. #> || ||
  1. say(fortune = "whatever")
  2. #>
  3. #> _________________________________________________________
  4. #> / Justin: Is there a function that just does whatever I'm \
  5. #> | thinking (aka whatever my homework question is...)? |
  6. #> | Joshua Ulrich: That's the magic_pony function. Justin |
  7. #> \ and Joshua Ulrich stackoverflow.com June 2013 /
  8. #> ---------------------------------------------------------
  9. #> \
  10. #> \
  11. #>
  12. #> ^__^
  13. #> (oo)\ ________
  14. #> (__)\ )\ /\
  15. #> ||------w|
  16. #> || ||

Trilobite

  1. say("Hi there :)", by = "trilobite")
  1. #>
  2. #> _____________
  3. #> < Hi there :) >
  4. #> -------------
  5. #> \
  6. #> \
  7. #>
  8. #> _____
  9. #> .'` ,-. `'.
  10. #> / ([ ]) \
  11. #> /.-""`(`)`""-.\
  12. #> <'```(.)```'>
  13. #> <'```(.)```'>
  14. #> <'``(.)``'>
  15. #> sk <``\_/``>
  16. #> `'---'`

Shark

  1. say("Q: What do you call a solitary shark\nA: A lone shark", by = "shark")
  2. #>
  3. #> ______________________________________________________
  4. #> < Q: What do you call a solitary shark A: A lone shark >
  5. #> ------------------------------------------------------
  6. #> \
  7. #> \
  8. #>
  9. #> /""-._
  10. #> . '-,
  11. #> : '',
  12. #> ; * '.
  13. #> ' * () '.
  14. #> \ \
  15. #> \ _.---.._ '.
  16. #> : .' _.--''-'' \ ,'
  17. #> .._ '/.' . ;
  18. #> ; `-. , \'
  19. #> ; `, ; ._\
  20. #> ; \ _,-' ''--._
  21. #> : \_,-' '-._
  22. #> \ ,-' . '-._
  23. #> .' __.-''; \...,__ '.
  24. #> .' _,-' \ \ ''--.,__ '\
  25. #> / _,--' ; \ ; \^.}
  26. #> ;_,-' ) \ )\ ) ;
  27. #> / \/ \_.,-' ;
  28. #> / ;
  29. #> ,-' _,-'''-. ,-., ; PFA
  30. #> ,-' _.-' \ / |/'-._...--'
  31. #> :--`` )/
  32. #> '

Buffalo

  1. say("Q: What do you call a single buffalo?\nA: A buffalonely", by = "buffalo")
  1. #>
  2. #> ________________________________________________________
  3. #> < Q: What do you call a single buffalo? A: A buffalonely >
  4. #> --------------------------------------------------------
  5. #> \
  6. #> \
  7. #>
  8. #> _.-````'-,_
  9. #> _,.,_ ,-'` `'-.,_
  10. #> /) ( '``-.
  11. #> (( ) ) `\
  12. #> \) (_/ )\
  13. #> | /) ' ,' / \
  14. #> `\ ^' ' ( / ))
  15. #> | _/\ , / ,,`\ ( "`
  16. #> \Y, | \ \ | ````| / \_ \
  17. #> `)_/ \ \ ) ( > ( >
  18. #> \( \( |/ |/
  19. #> mic & dwb /_(/_( /_( /_(

Clippy

  1. say(fortune = 59, by = "clippy")
  2. #>
  3. #> ________________________________________________________
  4. #> / Let's not kid ourselves: the most widely used piece of \
  5. #> | software for statistics is Excel. Brian D. Ripley |
  6. #> | 'Statistical Methods Need Software: A View of |
  7. #> | Statistical Computing' Opening lecture RSS 2002, |
  8. #> \ Plymouth September 2002 /
  9. #> --------------------------------------------------------
  10. #> \
  11. #> \
  12. #>
  13. #> _
  14. #> / \
  15. #> | |
  16. #> @ @
  17. #> || ||
  18. #> || ||
  19. #> |\_/|
  20. #> \___/ GB

Yoda

  1. say("fortune", by = "yoda")

Bats!

  1. say("hi, i'm a bat", by = "bat")
  2. #>
  3. #> _______________
  4. #> < hi, i'm a bat >
  5. #> ---------------
  6. #> \
  7. #> \
  8. #>
  9. #> __.--'\ \.__./ /'--.__
  10. #> _.-' '.__.' '.__.' '-._
  11. #> .' '.
  12. #> / \
  13. #> | |
  14. #> | |
  15. #> \ .---. .---. /
  16. #> '._ .' '.''. .''.' '. _.'
  17. #> '-./ \ / \.-'
  18. #> ''mrf

See also bat2

Monkey!

  1. say("fortune", by = "monkey")
  2. #>
  3. #> ________________________________________________________
  4. #> / Duncan Murdoch: Others need to run under ESS. Francois \
  5. #> | Pinard: While this is a good things for Emacs lovers, |
  6. #> | the requirement is rather unwelcome for pagans! :-) |
  7. #> | Duncan Murdoch and Francois Pinard on the availability |
  8. #> \ of command completion R-help May 2006 /
  9. #> --------------------------------------------------------
  10. #> \
  11. #> \
  12. #>
  13. #> .="=.
  14. #> _/.-.-.\_ _
  15. #> ( ( o o ) ) ))
  16. #> |/ " \| //
  17. #> \'---'/ //
  18. #> jgs /`"""`\\ ((
  19. #> / /_,_\ \\ \\
  20. #> \_\_'__/ \ ))
  21. #> /` /`~\ |//
  22. #> / / \ /
  23. #> ,--`,--'\/\ /
  24. #> '-- "--' '--'

Daemon!

  1. say("fortune", by = "daemon")
  2. #>
  3. #> _______________________________________________________
  4. #> / I wish <<- had never been invented, as it makes an \
  5. #> | esoteric and dangerous feature of the language *seem* |
  6. #> | normal and reasonable. If you want to dumb down R/S |
  7. #> | into a macro language, this is the operator for you. |
  8. #> \ Bill Venables R-help July 2001 /
  9. #> -------------------------------------------------------
  10. #> \
  11. #> \
  12. #> , ,
  13. #> /( )`
  14. #> \ \___ / |
  15. #> /- _ `-/ '
  16. #> (/\/ \ \ /\
  17. #> / / | `
  18. #> O O ) / |
  19. #> `-^--'`< '
  20. #> (_.) _ ) /
  21. #> `.___/` /
  22. #> `-----' /
  23. #> <----. __ / __ \
  24. #> <----|====O)))==) \) /====
  25. #> <----' `--' `.__,' \
  26. #> | |
  27. #> \ /
  28. #> ______( (_ / \______
  29. #> ,' ,-----' | \
  30. #> `--{__________) \/ [nosig]

Egret

  1. say("je ne regrette rien", by = "egret")
  2. #>
  3. #> _____________________
  4. #> < je ne regrette rien >
  5. #> ---------------------
  6. #> \
  7. #> \
  8. #>
  9. #> _,
  10. #> -==<' `
  11. #> ) /
  12. #> / (_.
  13. #> | ,-,`\
  14. #> \\ \ \
  15. #> `\, \ \
  16. #> ||\ \`|,
  17. #> jgs _|| `=`-'
  18. #> ~~`~`

See also bat2

Endless horse

With endless=FALSE cause we gotta compile the .md yo

  1. endless_horse(endless = FALSE)
  2. #>
  3. #> ______________
  4. #> < Hello world! >
  5. #> --------------
  6. #> \
  7. #> \
  8. #>
  9. #> ,
  10. #> _,,)\.~,,._
  11. #> (()` ``)\))),,_
  12. #> | \ ''((\)))),,_ ____
  13. #> |6` | ''((\())) "-.____.-" `-.-,
  14. #> | .'\ ''))))' \)))
  15. #> | | `. '' ((((
  16. #> \, _) \/ |))))
  17. #> `' | (((((
  18. #> \ | ))))))
  19. #> `| | ,\ /((((((
  20. #> | / `-.______.< \ | )))))
  21. #> | | / `. \ \ ((((
  22. #> | / \ | `.\ | (((
  23. #> \ | | | )| | ))
  24. #> | | | | || | ' [endless.horse]
  25. #> | | | | || |

Using pipes

  1. library("magrittr")
  2. "I HAD FUN ONCE, IT WAS AWFUL" %>% say("grumpycat")
  3. #>
  4. #> ______________________________
  5. #> < I HAD FUN ONCE, IT WAS AWFUL >
  6. #> ------------------------------
  7. #> \
  8. #> \
  9. #>
  10. #> ハ _ ハ
  11. #> ಠ X ಠ

I just want the animals!

Okay, hold your endless horses. Just use the function animal_fetch() to select the animal you want by name.

  1. animal_fetch("clippy")
  2. #> [1] "\n _\n / \\\n | |\n @ @\n || ||\n || ||\n |\\_/|\n \\___/ GB"

Meta

  • License: MIT
  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.