praise包--R给你点赞!

praise包--R给你点赞!

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()
[] "You are fine!"
> praise()
[] "You are divine!"
> praise()
[] "You are best!"
> praise()
[] "You are fantastic!"
> praise()
[] "You are wonderful!"
> praise()
[] "You are fantabulous!"
> praise()
[] "You are splendid!"

2.3自定义赞美格式

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

## 首字母大写
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[] "Yay! This program is lovely!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[] "Gee! This package is glorious!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[] "Yahoo! This program is super!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[] "Mhm! This package is fantastic!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[] "Yippie! This project is fine!"
> praise("${Exclamation}! This ${rpackage} is ${adjective}!")
[] "Ahh! This R package is super!"
## 所有字母大写
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[] "HUZZAH! You have done this really!"
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[] "AHHH! You have done this enthusiastically!"
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[] "HURRAY! You have done this warmly!"
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[] "OLE! You have done this kindly!"
> praise("${EXCLAMATION}! You have done this ${adverb_manner}!")
[] "HO-HO! You have done this swiftly!"

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

查看可用词库:

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

3.自定义启动环境

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

praise包--R给你点赞!

praise包--R给你点赞!

这个文件里,设置的内容包括默认编辑器,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则显示如下:

praise包--R给你点赞!

本文链接:

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

上一篇:LightGBM 调参方法(具体操作)


下一篇:RandomForest 随机森林算法与模型参数的调优