R中的wikifacts包
在本文中,我们将使用 R 编程语言的 wikifacts 包。我们将看看 wikifacts 包的几个功能,用于删除事件、事实和新闻等数据。
安装:
要安装此软件包,请在终端中键入以下命令。
install.packages(“wikifacts”)
wikifacts 是一个 R 包,可用于从 Wikipedia 和 wiki 数据中抓取数据。
获得单词的定义
wiki_define(“word”)函数:从 Wikipedia 和 wiki 数据中返回单词的定义。
句法:
wiki_define("word")
R
# installing packages
install.packages("wikifacts")
# importing packages
library(wikifacts)
# gets definition of the word
cat(wiki_define("python"))
R
# installing packages
install.packages("wikifacts")
# importing packages
library(wikifacts)
# returns the random news
cat(wiki_inthenews())
R
# installing packages
install.packages("wikifacts")
# importing packages
library(wikifacts)
# Gets random fact
cat(wiki_didyouknow())
# Get random fact from the past of
# current date
cat(wiki_onthisday())
输出:
Python may refer to:
Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
Python (genus), a genus of nonvenomous Pythonidae found in Africa and Asia
== Computing ==
Python (programming language)
Python, a native code compiler for CMU Common Lisp
Python, the internal project name for the PERQ 3 computer workstation
…..
获取新闻:
wiki_inthenews()函数:返回随机趋势新闻。
句法:
wiki_inthenews()
例子:
R
# installing packages
install.packages("wikifacts")
# importing packages
library(wikifacts)
# returns the random news
cat(wiki_inthenews())
输出:
Here’s some news from 07 October 2017. In Saudi Arabia, a decree by King Salman effectively removes a longstanding ban on women driving in the country. (Courtesy of Wikipedia)
获取随机事实:
wiki_didyouknow()函数:返回随机事实。
句法:
wiki_didyouknow()
wiki_onthisday()函数:返回当前日期过去的随机事实。
句法:
wiki_onthisday()
R
# installing packages
install.packages("wikifacts")
# importing packages
library(wikifacts)
# Gets random fact
cat(wiki_didyouknow())
# Get random fact from the past of
# current date
cat(wiki_onthisday())
输出:
Did you know that the population of Kunság (banner pictured) was “almost entirely wiped out” during the Ottoman occupation, before recovering through re-colonization? (Courtesy of Wikipedia)
Did you know that on March 9 in 1932 – Éamon de Valera (pictured), one of the dominant political figures in twentieth-century Ireland, became President of the Executive Council of the Irish Free State. (Courtesy of Wikipedia)