码迷,mamicode.com
首页 > 其他好文 > 详细

praise包--R给你点赞!

时间:2016-08-08 19:10:49      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

1.praise包干什么的?

  praise包就一个功能:赞你!

2.praise包怎么搞?

2.1安装

直接安装:

install.packages("praise")

从github上安装:

library(devtools)
install_github("gaborcsardi/praise")

2.2开始赞你

用法:

praise(template = "You are ${adjective}!")

使用随机的单词替换adjective来赞美你!

> library(praise)
> praise() [1] "You are fine!" > praise() [1] "You are divine!" > praise() [1] "You are best!" > praise() [1] "You are fantastic!" > praise() [1] "You are wonderful!" > praise() [1] "You are fantabulous!" > praise() [1] "You are splendid!"

2.3自定义赞美格式

可以看到,预设的赞美格式是You are ${adjective}!,此外还可以自定义格式!

## 首字母大写
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[1] "Yay! This program is lovely!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[1] "Gee! This package is glorious!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[1] "Yahoo! This program is super!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[1] "Mhm! This package is fantastic!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[1] "Yippie! This project is fine!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[1] "Ahh! This R package is super!"

 

## 所有字母大写
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[1] "HUZZAH! You have done this really!"
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[1] "AHHH! You have done this enthusiastically!"
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[1] "HURRAY! You have done this warmly!"
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[1] "OLE! You have done this kindly!"
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[1] "HO-HO! You have done this swiftly!"

其中 ${EXCLAMATION}${adjective}以及 ${adverb_manner},可以理解为包中的词库,分别表示感叹和情态,每个词库里面都含有数量不等的用于称赞你的词语!

查看可用词库:

> names(praise_parts)
[1] "adjective" "adverb" "adverb_manner" "created" "creating" "exclamation" "rpackage" 

3.自定义启动环境

打开R安装位置里的etc文件夹中的配置文件Rprofile.site文件:

 技术分享

技术分享

这个文件里,设置的内容包括默认编辑器,CRAN镜像选取,自动加载包等等

在打开Rprofile.site文档的最后加上如下代码:

.First <- function(){
library(praise)
  cat(praise("${EXCLAMATION}! ${EXCLAMATION}! Handsome man,you have done this ${adverb_manner}!"),"\n",praise(),"\n",praise(),"\n",date(),"\n")
}

重启RStudio则显示如下:

技术分享

 

本文链接:

http://www.cnblogs.com/homewch/p/5749850.html

praise包--R给你点赞!

标签:

原文地址:http://www.cnblogs.com/homewch/p/5749850.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!