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
| library(tidyverse) | |
| #### clear workspace #### | |
| rm(list=ls()) | |
| #### read in the html file and clean up the data #### | |
| msgs <- readLines("~/Documents/gosschat.html") | |
| msgs <- gsub(" ", msgs, replacement="__") | |
| msgs <- gsub("\"", msgs, replacement="##") | |
| msgs <- gsub("\'", msgs, replacement="##") |
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
| library(tidyverse) | |
| buzzes <- read_csv("~/Desktop/regs analysis/all_buzzes.csv") | |
| tossups_heard <- read_csv("~/Desktop/regs analysis/tossups_heard.csv") %>% | |
| filter(!is.na(Packet)) %>% | |
| group_by(Packet) %>% | |
| summarize(Heard = max(Heard)) | |
| tossups <- buzzes %>% |
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
| #!/usr/bin/Rscript --vanilla | |
| library(sp) | |
| #library(RColorBrewer) | |
| colorPalette <- colorRampPalette(c("white", "orange"))(32) | |
| spain <- readRDS("ESP_adm1.rds") | |
| # Datos de Informe Anual del Sector TIC y de los Contenidos en España 2016. ONTSI |
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
| library(rJava) | |
| library(coreNLP) | |
| initCoreNLP() | |
| #in this case, 'test' is a data frame with a col named 'text' | |
| for (i in 1:dim(test)[1]) { | |
| cat(paste0(i / dim(test)[1] * 100, '% completed')) | |
| ann <- annotateString(paste(test$text[i]), format = c("obj"), outputFile = NA, includeXSL = FALSE) | |
| gd <- getDependency(ann) |
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
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| """ | |
| python 2.x | |
| Scrape members from a Twitter list and then get their bios, locations, etc. | |
| Based on | |
| https://github.com/lamthuyvo/social-media-data-scripts/blob/master/scripts/twitter_bio_info_compiler.py | |
| and | |
| https://github.com/kylemanna/social-utils/blob/master/twitter/list-follow.py |
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
| library(rtweet) | |
| ## number of iterations | |
| n <- 5 | |
| ## to do a certain task (e.g., searching for tweets on a topic), | |
| ## twitter policy says you should use one token | |
| ## so select one token | |
| token <- get_tokens() | |
| if (!"Token" %in% class(token)) { |
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
| #!/usr/bin/Rscript | |
| if (!require(jsonlite, quietly = TRUE, warn.conflicts = FALSE)) { | |
| stop("This program requires the `jsonlite` package. Please install it by running `install.packages('jsonlite')` in R and then try again.") | |
| } | |
| args <- commandArgs(trailingOnly = TRUE) | |
| if (length(args) == 0) { | |
| input <- readLines(file("stdin")) |
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
| code | postal_code | name | phone_code | iso2 | |
|---|---|---|---|---|---|
| VI | 01 | Álava | 945 | ES | |
| AB | 02 | Albacete | 967 | ES | |
| A | 03 | Alacant | 950 | ES | |
| AL | 04 | Almería | 920 | ES | |
| AV | 05 | Ávila | 924 | ES | |
| BA | 06 | Badajoz | 924 | ES | |
| PM | 07 | Illes Balears | 971 | ES | |
| B | 08 | Barcelona | 93 | ES | |
| BU | 09 | Burgos | 947 | ES |
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
| # Proof of concept of using V8 to parse HTML in R | |
| # Example taken from rvest readme | |
| # Jeroen Ooms, 2015 | |
| library(V8) | |
| stopifnot(packageVersion("V8") >= "0.4") | |
| # Get Document | |
| html <- paste(readLines("http://www.imdb.com/title/tt1490017/"), collapse="\n") |
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
| ############################################################################################### | |
| ## ## | |
| ## Setup ## | |
| ## ## | |
| ############################################################################################### | |
| # install.packages("Rfacebook") # from CRAN | |
| # install.packages("Rook") # from CRAN | |
| # install.packages("igraph") # from CRAN |