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
*.acn | |
*.acr | |
*.alg | |
*.aux | |
*.bak | |
*.bbl | |
*.bcf | |
*.blg | |
*.brf | |
*.bst |
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
# Latex files | |
*.aux | |
*.glo | |
*.idx | |
*.log | |
*.toc | |
*.ist | |
*.acn | |
*.acr |
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
# sources: | |
# http://www.jgoodwin.net/?p=1223 | |
# http://orgtheory.wordpress.com/2012/05/16/the-fragile-network-of-econ-soc-readings/ | |
# http://nealcaren.web.unc.edu/a-sociology-citation-network/ | |
# http://kieranhealy.org/blog/archives/2014/11/15/top-ten-by-decade/ | |
# http://www.jgoodwin.net/lit-cites.png | |
########################################################################### | |
# This first section scrapes content from the Web of Science webpage. It takes |
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
path = "~/Documents/My Data/BRAZIL/Elections/" | |
out.file<-"" | |
file.names <- dir(path, pattern =".txt") | |
for(i in 1:length(file.names)){ | |
file <- read.table(file.names[i],header=TRUE, sep=";", stringsAsFactors=FALSE) | |
out.file <- rbind(out.file, file) | |
} | |
write.table(out.file, file = "cand_Brazil.txt",sep=";", | |
row.names = FALSE, qmethod = "double",fileEncoding="windows-1252") | |
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
# This script uses httr to download data from Google's API | |
# Notice ther is a limit of 2,500 calls per day | |
library(httr) | |
base_url <- "http://maps.google.com/maps/api/geocode/json" | |
geoCode <- function(address,verbose=FALSE) { | |
r <- GET(base_url, query = list(address = address, sensor = "false")) | |
stop_for_status(r) | |
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
# Helper functions that allow string arguments for dplyr's data modification functions like arrange, select etc. | |
# Author: Sebastian Kranz | |
# Examples are below | |
#' Modified version of dplyr's filter that uses string arguments | |
#' @export | |
s_filter = function(.data, ...) { | |
eval.string.dplyr(.data,"filter", ...) | |
} |
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(httr) | |
library(XML) | |
library(selectr) | |
xpath <- function(x) structure(x, class = "xpath") | |
sel <- function(x) xpath(css_to_xpath(x, prefix = "//")) | |
url <- "http://www.boxofficemojo.com/movies/?id=ateam.htm" | |
html <- content(GET(url), "parsed") |
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
# Set up RStudio and JAGS on an Amazon EC2 instance | |
# Using Ubuntu 64-bit | |
# Partially from http://blog.yhathq.com/posts/r-in-the-cloud-part-1.html | |
# See yhat for EC2 instance set up | |
# Navigate to key pair | |
# ssh -i YOUR_KEYPAIR.pem ubuntu@PUBLIC_DNS | |
# Add a user/password. | |
# This will become your RStudio username and password. |
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
pkgs <- c("party", "parallel") | |
invisible(lapply(pkgs, require, character.only = TRUE)) | |
partial_dependence <- function(fit, ivar, cores = 1, ...) { | |
## calculates the partial dependence of the response on explanatory variable(s) | |
## fit must be a party object | |
## ivar must be a character vector of length >= 1 all of which | |
## exist in the dataframe used to fit the model | |
## if the length of ivar > 1, joint dependence is calculated | |
df <- data.frame(get("input", fit@data@env), get("response", fit@data@env)) |
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(ggplot2) | |
library(pipeR) | |
library(rCharts) | |
#using ggplot2 stat_density help example | |
library(plyr) # to access round_any | |
movies$decade <- round_any(movies$year, 10) | |
OlderNewer