开发者

What are fortunes?

In R, one sometime sees people making references to fortunes. For example:

fortune(108)

Wh开发者_如何学Cat does this mean? Where does this originate? Where can I get the code?

Edit. The sharp-eyed reader would have noticed that this question marks the 5,000th question with the [r] tag. Forgive the frivolity, but such a milestone should be marked with a bit of humour. For an extra bit of fun, you can provide an answer with your favourite fortune cookie.


It refers to the fortunes package, which is a package that contains a whole set of humorous quotes and comments from the help lists, conferences, fora and even StackOverflow.

It is actually a database or small dataframe you can browse through.

library(fortunes)
fortune()

To get a random one. Or look for a specific one, eg :

> fortune("stackoverflow")

datayoda: Bing is my friend...I found the cumsum() function.
Dirk Eddelbuettel: If bing is your friend, then rseek.org is bound 
to be your uncle.
   -- datayoda and Dirk Eddelbuettel (after searching for a function that 
      computes cumulative sums)
      stackoverflow.com (October 2010)

If you want to get all of them in a dataframe, just do

MyFortunes <- read.fortunes()

The numbers sometimes referred to, are the row numbers of this dataframe. To find everything on stackoverflow :

> grep("(?i)stackoverflow",MyFortunes$source)
[1] 273 275
> fortune(275)

I used a heuristic... pulled from my posterior. That makes it Bayesian, right?
   -- JD Long (in a not too serious chat about modeling strategies)
      Stackoverflow (November 2010)


And for the record, 108 is is this one:

R> library(fortunes)
R> fortune(108)

Actually, I see it as part of my job to inflict R on people who are 
perfectly happy to have never heard of it. Happiness doesn't equal 
proficient and efficient. In some cases the proficiency of a person 
serves a greater good than their momentary happiness.
   -- Patrick Burns
      R-help (April 2005)

R> 


They're humorous (sometimes snarky) comments collected from the R lists.

install.packages("fortunes")

Or more generally

install.packages("sos")
library("sos")
findFn("fortune")


A quick search on CRAN turns up the fortunes package, which basically just prints random witty quotes related to R. The concept is based on the fortune program from Unix.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜