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
get_timeline_df <- function(user, n_tweets=200, oauth_sig) { | |
i <- 0 | |
n_left <- n_tweets | |
timeline_df <- NULL | |
#loop until n_tweets are all got | |
while (n_left > 0) { | |
n_to_get <- min(200, n_left) | |
i <- i+1 | |
#incorporae max id in get_url (so as not to download same 200 tweets repeatedly) | |
if (i==1) { |
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
################################################################## | |
# ADDRESSING https://github.com/AdamSpannbauer/lexRankr/issues/8 | |
################################################################## | |
# GET EXAMPLE DATA | |
#---------------------------------------------------------- | |
library(xml2) | |
library(rvest) | |
options(stringsAsFactors = FALSE) |
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
################################################################## | |
# ADDRESSING https://github.com/AdamSpannbauer/lexRankr/issues/8 | |
################################################################## | |
# Monduiz'S EXAMPLE CODE | |
################################################################## | |
library(rvest) | |
library(tidyverse) | |
library(stringr) | |
library(purrr) |
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(data.table) | |
library(gganimate) | |
library(ggplot2) | |
#toy example data | |
dt = data.table(time=1:10, x=round(runif(10, 50, 100), 0)) | |
#number of frames per bar | |
n_frames_per_bar = 20 | |
#create sequence per time (to imitate the bar growing from ground) |
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
#load needed packages | |
library(xml2) | |
library(rvest) | |
library(lexRankr) | |
#url to scrape | |
my_url = "http://www.freepatentsonline.com/y2014/0278285.html" | |
#read page html | |
page = xml2::read_html(my_url) |
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
#current preferred version of wc2 | |
devtools::install_github("Lchiffon/wordcloud2#32") | |
#function to give wordcloud2 click interactivity | |
wc2ClickedWord = function(cloudOutputId, inputId) { | |
#ARGUMENTS | |
# - cloudOutputId: string; outputId of wordcloud2 obj being rendered (should be identical to the value passed to wordcloud2Output) | |
# - inputId: string; inputId of word clicked on (ie you will reference in server the word by input$inputId) | |
#OUPUT | |
# - referencing input in server will return a string of form word:freq (same as hover info shown in wordcloud; ie 'super:32') |
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
import os | |
import re | |
from pytube import YouTube | |
def downloadYtMp4(ytURL, dlDir=os.getcwd()): | |
#find youtube video | |
yt = YouTube(ytURL) | |
# | |
#filter to only mp4 files and take last in list (sorted lowest to highest quality) | |
hqMp4 = yt.filter('mp4')[-1] |
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
create_query_chunker = function(query, | |
dbi_connection, | |
post_process_func=NULL, | |
chunk_size=5000L, | |
debug_print=FALSE) { | |
#' @title Create a chunked query fetcher | |
#' | |
#' @description Creates a generator function that can be repeatedly | |
#' called to return the next n rows of query (where n = \code{chunk_size}) | |
#' |
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(R6) | |
QueryChunker = R6Class('QueryChunker', | |
public = list( | |
query = NULL, | |
chunk_query = NULL, | |
connection = NULL, | |
post_process_func = NULL, | |
chunk_size = 1000L, | |
offset_size = 0, |
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
## install PR of wordcloud2 that adds click events | |
# devtools::install_github("Lchiffon/wordcloud2#35") | |
library(shiny) | |
library(shinyjs) | |
library(wordcloud2) | |
# define dummy data to use in example | |
wordcloud_df = data.frame(word = c('bing', 'google'), | |
freq = c(1, 2), |
OlderNewer