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(pitchRx) | |
library(dplyr) | |
library(mgcv) | |
# Establish a SQLite database connection | |
my_db <- src_sqlite("pitchRx.sqlite3") | |
# DISLCAIMER: this 'pitchfx.sqlite3' database was obtained using pitchRx version 1.2 | |
# The code below probably won't work if you are using data collected from earlier versions or other methods | |
# Anyway, if you want to recreate this analysis, make sure you have pitchRx 1.2 or higher, then run: |
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
require(igraph) | |
# generate a social graph | |
node_number = 100 | |
g = barabasi.game(node_number) ; plot(g) | |
seeds_num = 1 | |
set.seed(2014); diffusers = sample(V(g),seeds_num) ; diffusers | |
infected =list() | |
infected[[1]]= diffusers |
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(mnormt) | |
mycols <- topo.colors(100,0.5) | |
xhat <- c(0.2, -0.2) | |
Sigma <- matrix(c(0.4, 0.3, | |
0.3, 0.45), ncol=2) | |
x1 <- seq(-2, 4,length=151) | |
x2 <- seq(-4, 2,length=151) | |
f <- function(x1,x2, mean=xhat, varcov=Sigma) | |
dmnorm(cbind(x1,x2), mean,varcov) | |
z <- outer(x1,x2, f) |
This file has been truncated, but you can view the full file.
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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:6eedb0030499d0d2d3e9771cf5de62fde633f5875dd94bf121c4f7f2dc2849c1" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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(shiny) | |
library(shinydashboard) | |
library(sparkline) | |
library(httr) | |
library(jsonlite) | |
library(data.table) | |
library(dplyr) | |
library(rvest) | |
library(magrittr) | |
library(XML) |
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(dplyr) | |
library(tidyr) | |
library(magrittr) | |
library(ggplot2) | |
"http://academic.udayton.edu/kissock/http/Weather/gsod95-current/NYNEWYOR.txt" %>% | |
read.table() %>% data.frame %>% tbl_df -> data | |
names(data) <- c("month", "day", "year", "temp") | |
data %>% | |
group_by(year, month) %>% |
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
#Script for scraping Chronicling America | |
import requests | |
import re | |
import csv | |
from bs4 import BeautifulSoup, SoupStrainer | |
import os | |
from time import sleep | |
from datetime import date, datetime, timedelta | |
#search_terms is a string of words separated by spaces. |
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(KoNLP) | |
library(wordcloud) | |
library(plyr) | |
library(ggplot2) | |
library(scales) | |
tw <- read.delim('./data/NIS.csv', header=T, sep=',', stringsAsFactors=F) | |
tw.RT <- read.delim('./data/NIS_RT.csv', header=T, sep=',', stringsAsFactors=F) | |
tw.all <- read.delim('./data/NIS_withRT.csv', header=T, sep=',', | |
stringsAsFactors=F) |
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
# -*- coding: utf-8 -*- | |
""" | |
Python: 3.4.2 | |
author: dokenzy | |
date: 2015. 4. 21 | |
license: MIT License | |
""" | |
import os |
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
recipes = readLines('recipes combined.tsv') | |
# Once I read it into R, I have to get rid of the /t | |
# characters so that it's more acceptable to the tm package | |
recipes.new = apply(as.matrix(recipes), 1, function (x) gsub('\t',' ', x)) | |
recipes.corpus = Corpus(VectorSource(recipes.new)) | |
recipes.dtm = DocumentTermMatrix(recipes.corpus) |