且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

《R的极客理想—工具篇》—— 1.3 fortunes 记录R语言的大智慧

更新时间:2022-10-07 22:48:21

本节书摘来自华章出版社《R的极客理想—工具篇》一 书中的第1章,第1.3节,作者:张丹,更多章节内容可以访问云栖社区“华章计算机”公众号查看。

1.3 fortunes 记录R语言的大智慧

问题
如何才能更深入地了解R, 它的起源、成长、经历是怎样的?
《R的极客理想—工具篇》—— 1.3 fortunes 记录R语言的大智慧

引言
R语言是在大数据“火”起来后,映入人们眼球的。但R语言的社区已经存在很多年,我们并不知道,R语言在很长的历史时期,有着什么样的智慧。不过,正有人悄悄地记录着R语言的大智慧。

1.3.1 fortunes介绍

fortunes库是一个R语言的语录集,截至2013年12月14日,一共总结了360条R-help的留言。这些都是R语言智慧的精华,让R语言的后辈使用者,可以更了解R语言的本身,了解R的精神。

1.3.2 fortunes安装

本节使用的系统环境是:

Linux: Ubuntu 12.04.2 LTS 64bit
R: 3.0.1 x86_64-pc-linux-gnu

注 fortunes同时支持Windows 7环境和Linux环境。
Fortunes的安装过程如下。

~ R  # 启动R程序
> install.packages("fortunes")  # 安装fortunes包
> library(fortunes)  # 加载fortunes包
> ?fortunes  #查看帮助
1.3.3 fortunes包的使用
fortunes包的使用非常简单,只有一个函数fortune()。
> fortune()  # 随机查看一条语录
Barry Rowlingson: Your grid above has 8*6 = 42 points.
(That was a subtle Hitchhikers Guide To The Galaxy reference there, honest, and
not a stupid dumb multiplication mistake on my part after working four 18-hour
days on the trot...)
Peter Dalgaard: [...] Don't panic, just throw yourself at the ground and miss.
   -- Barry Rowlingson and Peter Dalgaard
      R-help (March 2004)

> 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)

完整的语录下载地址是cran.r-project.org/web/packages/fortunes/vignettes/fortunes.pdf。静下心来阅读这些智慧精华就能更了解R语言本身。想用好一门语言,就需要更深入地了解它。