wikifacts package in R
Last Updated :
18 Mar, 2022
In this article, we will be working with wikifacts package of R Programming Language. We will have a look at several functions of wikifacts package to scrap data like events, facts, and news.
Installation:
To install this package type the below command in the terminal.
install.packages(“wikifacts”)
wikifacts is an R package that can be used to scrape data from Wikipedia and wiki data.
Getting Definition of words
wiki_define(“word”) function: Returns the definition of the words from Wikipedia and wiki data.
Syntax:
wiki_define("word")
R
install.packages ( "wikifacts" )
library (wikifacts)
cat ( wiki_define ( "python" ))
|
Output:
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
…..
Get news:
wiki_inthenews() function: Returns the random trending news.
Syntax:
wiki_inthenews()
Example:
R
install.packages ( "wikifacts" )
library (wikifacts)
cat ( wiki_inthenews ())
|
Output:
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)
Get random facts:
wiki_didyouknow() function: returns the random fact.
Syntax:
wiki_didyouknow()
wiki_onthisday() function: returns random facts from the past of the current date.
Syntax:
wiki_onthisday()
R
install.packages ( "wikifacts" )
library (wikifacts)
cat ( wiki_didyouknow ())
cat ( wiki_onthisday ())
|
Output:
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)
Share your thoughts in the comments
Please Login to comment...