在R中,人们有时会看到人们提到财富.例如:
fortune(108)
Run Code Online (Sandbox Code Playgroud)
这是什么意思?这起源于哪里?我在哪里可以获得代码?
编辑. 眼尖的读者会注意到这个问题标5,000th有[r]标签的问题.原谅轻浮,但这样一个里程碑应该用一点幽默来标记.为了获得额外的乐趣,您可以使用自己喜欢的fortunecookie 提供答案.
Jor*_*eys 18
它指的是fortunes包,它是一个包含一整套幽默引用和帮助列表,会议,论坛甚至StackOverflow的评论的包.
它实际上是一个可以浏览的数据库或小型数据帧.
library(fortunes)
fortune()
Run Code Online (Sandbox Code Playgroud)
随机获得一个.或者寻找特定的一个,例如:
> 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)
Run Code Online (Sandbox Code Playgroud)
如果你想在数据帧中获取所有这些,那就行了
MyFortunes <- read.fortunes()
Run Code Online (Sandbox Code Playgroud)
有时提到的数字是该数据帧的行号.要在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)
Run Code Online (Sandbox Code Playgroud)
Dir*_*tel 10
而对于记录,108是这一个:
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>
Run Code Online (Sandbox Code Playgroud)
它们是从 R 列表中收集的幽默(有时是尖酸刻薄)的评论。
install.packages("fortunes")
Run Code Online (Sandbox Code Playgroud)
或者更一般地说
install.packages("sos")
library("sos")
findFn("fortune")
Run Code Online (Sandbox Code Playgroud)