Created
June 2, 2020 06:31
-
-
Save brandmaier/729896d7f534d3e1075508934260faa2 to your computer and use it in GitHub Desktop.
Create histogram from Pokémon puzzle challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rtweet) | |
library(stringr) | |
# get last 100 tweets | |
tweets <- search_tweets("jonasobleser",n = 100) | |
# extract numbers with one or more digits | |
numbers <- sapply(tweets$text, | |
function(x) { | |
as.numeric(str_extract(x, "([0-9]+)")) | |
}) | |
# plot histogram | |
hist(numbers, main = paste0("Mean = ", | |
round(mean(numbers, na.rm = TRUE)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fantastic. It seems like 18,000 is the limit for the function, but setting
retryonratelimit
to TRUE might let you fetch more.