This file contains hidden or 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
var Twitter = require('node-tweet-stream') | |
, t = new Twitter({ | |
consumer_key: '', | |
consumer_secret: '', | |
token: '', | |
token_secret: '' | |
}); | |
var watch = [ | |
"SB52", | |
"SBLII", |
This file contains hidden or 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
s <- 'Frankly there is absolutely no collusion…Virtually every Democrat has said there is no collusion. There is no collusion…I think it’s been proven that there is no collusion…I can only tell you that there is absolutely no collusion…There’s been no collusion…There was no collusion. None whatsoever…everybody knows that there was no collusion. I saw Dianne Feinstein the other day on television saying there is no collusion [note: not true]…The Republicans, in terms of the House committees, they come out, they’re so angry because there is no collusion…there was collusion on behalf of the Democrats. There was collusion with the Russians and the Democrats. A lot of collusion…There was tremendous collusion on behalf of the Russians and the Democrats. There was no collusion with respect to my campaign…But there is tremendous collusion with the Russians and with the Democratic Party…I watched Alan Dershowitz the other day, he said, No. 1, there is no collusion, No. 2, collusion is not a crime, but even if it was a |
This file contains hidden or 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
let http = require('http'); | |
let https = require('https'); | |
let fs = require('fs'); | |
let cheerio = require('cheerio') | |
var letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']; | |
fs.writeFile('report.csv', "Name,Grades,County,City,Link\r\n", function(){console.log('done')}); | |
for(var i=0;i<letters.length;i++) { | |
scrape(letters[i]); | |
} |
This file contains hidden or 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
termination_words <- toupper(as.character(sapply(unlist(strsplit(text,'\\.')),function(x) { | |
words <- unlist(strsplit(x,' ')) | |
return(words[length(words)]) | |
}))) |
This file contains hidden or 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
html.data.frame <- function(table,id="records") { | |
df <- data.frame(table) | |
for(i in 1:ncol(df)) { | |
df[,i] <- as.character(df[,i]) | |
df[,i] <- gsub("&", "&", df[,i]) | |
df[,i] <- gsub("<", "<", df[,i]) | |
df[,i] <- gsub(">", ">", df[,i]) | |
} | |
html <- paste0('<table id="',id,'">') | |
html <- paste0(html,"<thead><tr><td>",paste(names(df),collapse = "</td><td>"),"</td></tr></thead><tbody>") |
This file contains hidden or 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
setwd("~/R/Merge Stuff") | |
install.packages("openxlsx") | |
library("openxlsx") | |
file <- list() | |
#base file is the original you are working from | |
#update file is the file with new information which updates base cells | |
#error file contains information in new columns which are appended | |
file$base <- read.xlsx("base.xlsx") | |
file$update <- read.xlsx("update.xlsx") |
This file contains hidden or 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
var http = require('http'); | |
var https = require('https'); | |
var fs = require('fs'); | |
var post_array = []; | |
var user_array = []; | |
fs.writeFile('posts.csv', 'Author,ID,Post Date,Comments,Score,Stickied,Pull,Subreddit\n', function(){console.log('Cleared posts.csv')}); | |
fs.writeFile('users.csv', 'Author,Author Date\n', function(){console.log('Cleared users.csv')}); | |
subreddits = ["all"] | |
for (var i=0;i<subreddits.length; i++) { |
This file contains hidden or 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
#https://www.washingtonpost.com/news/the-fix/wp/2016/10/19/the-final-trump-clinton-debate-transcript-annotated/ | |
transcript <- read.csv(file="~/R/reddit/speach/import/transcript-3rd-debate.csv",header = FALSE, stringsAsFactors = FALSE) | |
colnames(transcript) <- c("candidate","statement") | |
transcript_melted <- matrix(data="NA",nrow = 0,ncol = 2) | |
for(i in 1:nrow(transcript)) { | |
#removes non alphanumeric, then splits statement into a vector of words | |
words <- unlist(strsplit(gsub("[^[:alnum:] ]", "", transcript[i,"statement"]), " ")) | |
for(word in words) { | |
transcript_melted <- rbind(transcript_melted, c(transcript[i,"candidate"],word)) | |
} |
This file contains hidden or 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
#https://www.washingtonpost.com/news/the-fix/wp/2016/10/09/everything-that-was-said-at-the-second-donald-trump-vs-hillary-clinton-debate-highlighted/ | |
transcript <- read.csv(file="~/R/reddit/speach/import/transcript-2nd-debate.csv",header = FALSE, stringsAsFactors = FALSE) | |
colnames(transcript) <- c("candidate","statement") | |
transcript_melted <- matrix(data="NA",nrow = 0,ncol = 2) | |
for(i in 1:nrow(transcript)) { | |
#removes non alphanumeric, then splits statement into a vector of words | |
words <- unlist(strsplit(gsub("[^[:alnum:] \']", "", transcript[i,"statement"]), " ")) | |
for(word in words) { | |
transcript_melted <- rbind(transcript_melted, c(transcript[i,"candidate"],word)) | |
} |
This file contains hidden or 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
#https://www.washingtonpost.com/news/the-fix/wp/2016/09/26/the-first-trump-clinton-presidential-debate-transcript-annotated/ | |
transcript <- read.csv(file="~/R/reddit/speach/import/transcript.csv",header = FALSE, stringsAsFactors = FALSE) | |
colnames(transcript) <- c("candidate","statement") | |
transcript_melted <- matrix(data="NA",nrow = 0,ncol = 2) | |
for(i in 1:nrow(transcript)) { | |
#removes non alphanumeric, then splits statement into a vector of words | |
words <- unlist(strsplit(gsub("[^[:alnum:] \']", "", transcript[i,"statement"]), " ")) | |
for(word in words) { | |
transcript_melted <- rbind(transcript_melted, c(transcript[i,"candidate"],word)) | |
} |