Closed infospourmoi closed 4 years ago
non trovo la funzione "%>%"
just means that you need dplyr or magrittr installed. Lets focus on the first issue. Can you set:
n_facts <- 1
date <- Sys.Date() - 1
bare_fact <- FALSE
Then run the following lines of code:
date <- as.Date(date)
date1 <- format(date, "%Y_%B_")
date2 <- gsub("^0+", "", format(date, "%d"))
date_str <- paste0(date1, date2)
input <- paste0("https://en.wikipedia.org/wiki/Wikipedia:Main_Page_history/", date_str)
If you get an error let me know, otherwise let me know what input
looks like. Thanks!
This is what I get:
n_facts <- 1 date <- Sys.Date() - 1 barefact <- FALSE date <- as.Date(date) date1 <- format(date, "%Y%B_") date2 <- gsub("^0+", "", format(date, "%d")) date_str <- paste0(date1, date2) input <- paste0("https://en.wikipedia.org/wiki/Wikipedia:Main_Page_history/", date_str)
Can you type input
and let me know what gets returned?
date <- as.Date(date) date1 <- format(date, "%Y%B") date2 <- gsub("^0+", "", format(date, "%d")) date_str <- paste0(date1, date2) input <- paste0("https://en.wikipedia.org/wiki/Wikipedia:Main_Page_history/", date_str) input [1] "https://en.wikipedia.org/wiki/Wikipedia:Main_Page_history/2020_Giugno_13"
Ahhhhh! The function expects the date to be formatted in English. Can you try running this:
Sys.setlocale("LC_TIME", "en_GB.UTF-8")
And then try running wiki_randomfact(n_facts = 10, bare_fact = TRUE)
again
Yes We Can:
wiki_randomfact(n_facts = 10, bare_fact = TRUE) [1] "... that the Manhattan Project's liquid thermal diffusion plant was the only production-scale plant of its kind ever built?"
[2] "... that many coral diseases, such as black band disease (pictured), are named after their main symptom?"
[3] "... that the manga series A Man and His Cat was initially self-published, with entries posted weekly on the author's Twitter account?"
[4] "1701 – Scottish privateer William Kidd (pictured) was executed for piracy."
[5] "Edgar Lungu of the Patriotic Front party is elected President of Zambia."
[6] "... that Bill Gates has participated in the RedditGifts gift exchange service for five years, with the username \"thisisbillgates\"?"
[7] "1812 – Peninsular War: After a three-week siege, the Anglo-Portuguese Army, under the Earl of Wellington, captured Badajoz, Spain, and forced the surrender of the French garrison." [8] "... that Queen Tamaeva V saved the Rimatara lorikeet (pictured) from extinction through a royal taboo that forbade her people from harming or exporting the birds?"
[9] "Climate strikes take place in 150 countries (protesters in Sydney pictured) as part of the Fridays for Future protests."
[10] "An earthquake strikes Hualien, Taiwan, killing at least 17 people and injuring more than 280 others."
Also workin now:
wiki_didyouknow('cat')
By the way, today is the 14th, why was it indicating 13th before? Wikipedia server's time?
The function looks for yesterday by default, because Wikipedia's timezone is Pacific time I believe, so it would fail for today for a lot of people in Europe and Asia. Thanks for raising this. I'll close this issue and open a new one to highlight the problem.
Mac (Catilina) Wikifacts 0.3.0 (just installed)
library(wikifacts) library(devtools) library(dplyr) library(tidyverse)
Or,