knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", fig.align = "center" ) set.seed(130)
# Install development version from GitHub # install.packages("devtools") devtools::install_github("AQLT/jokeR")
To print a random joke you can use the function random_joke()
:
library(jokeR) random_joke()
You can also specify from which database you want a random joke and on which categories (use joke_categories()
to check the available ones). For example to only have jokes religious and animal jokes:
random_joke(categories = c("Animal", "Animals", "Religious"))
To print a message each time you open your session the most simple is to edit your Rprofile.site
file. If R is installed in C:\Program Files\R\R-n.n.n
this file will be located in the C:\Program Files\R\R-n.n.n\etc
directory. You can also use the function:
edit_rprofile.site()
Then, if you use RStudio, you can add the following command to print a message each time you open RStudio (thanks davidgohel for the tip!):
setHook("rstudio.sessionInit", function(newSession) { if (newSession){ print(jokeR::random_joke()) } }, action = "append")
Otherwise you can also change the .First()
function:
.First <- function() { print(jokeR::random_joke()) }
For the moment the database are from https://github.com/taivop/joke-dataset (jokes from stupidstuff and wocka).
Have more and smaller databases on various topics: jokes, citations, poems, etc.
Add category argument to jokes.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.