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
#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
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), |
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/Draw a Binary Fractal Tree | |
library(plotly) | |
# basic strucure for line shape in plotly | |
base_line = list( | |
type = "line", | |
line = list(color = "black"), | |
xref = "x", | |
yref = "y", |
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/Draw a Binary Fractal Tree | |
library(ggplot2) | |
library(uuid) | |
options(stringsAsFactors = FALSE) | |
# create line segment from (0, 0) to (0, len) to be trunk of fractal tree | |
create_trunk = function(len = 1) { | |
end_point = c(0, len) | |
trunk_df = data.frame(x=c(0, 0), |
OlderNewer