R Fortunes

Description

Read and print R fortunes.

Usage

fortune(which = NULL, fortunes.data = NULL, fixed = TRUE,
        showMatches = FALSE, author = character(), ...)
## S3 method for class 'fortune'
print(x, width = NULL, ...)
read.fortunes(file = NULL)

Arguments

which an integer specifying the row number of fortunes.data. Alternatively which can be a character and grep is used to try to find a suitable row.
fortunes.data data frame containing a fortune in each row. By default the fortune data from the fortunes package are used.
fixed logical passed to grep if which is a character, indicating if it should work (if TRUE, as by default) with a simple character string or (if FALSE) with regular expressions.
showMatches if which is character, a logical indicating if fortune() should print all the row numbers of fortunes.data which match the grep search.
author a character string to match (via grep) to the “authors” column of fortunes.data.
potential further arguments passed to grep.
x an object of class “fortune”, usually a single row from fortunes.data.
width integer specifying the character width. By default getOption(“width”) is used.
file a character string giving a fortune database in csv format (in UTF-8 encoding). By default all csv files in the data directory of the fortune package are used.

Value

fortune() returns an object of class “fortune” which is a row from a data frame of fortunes (like those read in from read.fortunes).

read.fortunes() returns a data frame of fortunes, each row contains:

quote the quote, main part of the fortune,
author the author of the quote,
context the context in which it was quoted (if available, otherwise NA),
source where it was quoted (if available, otherwise NA),
date when it was quoted (if available, otherwise NA).

Examples

library("fortunes")

fortune() # a random one

.RData files (the ones with nothing before the period) are just traps for your
future self, with no documentation. I avoid them like the plague.
   -- Jeff Newmiller (in a discussion on whether to store certain defaults in
      .Rprofile or .RData files)
      R-help (March 2015)
fortune("Ripley") # a random one from those with 'Ripley'

It really is hard to anticipate just how silly users can be.
   -- Brian D. Ripley
      R-devel (October 2003)
fortune(author = "Ripley") # a random one from those by 'Ripley'

'They' did write documentation that told you that Perl was needed, but 'they'
can't read it for you.
   -- Brian D. Ripley
      R-help (February 2001)

I plan to fix this - the report is just in case I forget or get hit by a bus.
   -- Ross Ihaka (reporting a bug in persp)
      R-help (October 2003)
fortune("parse", showMatches = TRUE) # -> shows at least 5 matches
Matching row numbers: 38, 106, 129, 181, 226 

If the answer is parse() you should usually rethink the question.
   -- Thomas Lumley
      R-help (February 2005)
fortune("parse.*answer") # nothing found but...
character(0)
fortune("parse.*answer", fixed = FALSE) # ...this works

Personally I have never regretted trying not to underestimate my own future
stupidity.
   -- Greg Snow (explaining why eval(parse(...)) is often suboptimal, answering
      a question triggered by the infamous fortune(106))
      R-help (January 2007)
## The first three "all together"   ('setNames()' requires at least R 3.0.0):
lapply(setNames(, c(38, 106, 129)), fortune)
$`38`

For almost 40 years SAS has been the primary tool for statisticians worldwide
and its easy-to-learn syntax, unsurpassed graphical system, powerful macro
language and recent graphical user interfaces have made SAS the number one
statistical software choice for both beginners and advanced users.
   -- Rolf Poalis, Biostatistics Denmark (announcement of the SAS to R parser
      sas2R)
      R-help (April 1, 2004)


$`106`

If the answer is parse() you should usually rethink the question.
   -- Thomas Lumley
      R-help (February 2005)


$`129`

See pages 45 and 46 of V&R's S PROGRAMMING for a definitive discussion of how
to do this.
(Confession: I treat anything that V&R say as definitive).
   -- Berton Gunter (in reply to the question how to parse a '...' function
      argument)
      R-help (June 2005)