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
x <- c(1,2,3) | |
plot(x) |
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
#generate data | |
library(MASS) | |
covvar <- matrix(c(1,.6,.6,.6,1,.6,.6,.6,1),nr = 3) | |
means <- c(20,25,30) | |
data <- as.data.frame(mvrnorm(100,means,covvar)) | |
#dichotomize the dependent variable | |
data$V1 <- ifelse(data$V1 > 20,1,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
library(MASS) | |
library(ggplot2) | |
#generate the fake data | |
covvar <- matrix(c(1,.6,.6,.6,1,.6,.6,.6,1),nr = 3) | |
means <- c(20,25,30) | |
data <- as.data.frame(mvrnorm(100,means,covvar)) | |
#dichotomize the dependent variable | |
data$V1 <- ifelse(data$V1 > 20,1,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
#read the ggplot2 library | |
library(ggplot2) | |
#read the data | |
mepDat <- read.csv("ep6.csv") | |
#plot the density for the questions variable | |
plot <- ggplot(mepDat, aes(x = Questions)) | |
plot <- plot + geom_density() | |
plot <- plot + geom_segment(aes(x = median(mepDat$Questions), xend = median(mepDat$Questions), y = 0, yend = .031), linetype = 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
library(tikzDevice) | |
library(ggplot2) | |
y <- exp(seq(1,10,.1)) | |
x <- 1:length(y) | |
data <- data.frame(x = x, y = y) | |
tikz(file = "test.tex") | |
plot <- ggplot(data, aes(x = x, y = y)) + geom_line() |
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
\documentclass{article} | |
\usepackage{tikz} | |
\begin{document} | |
\begin{figure}[ht] | |
\input{test.tex} | |
\caption{Sample output from tikzDevice} | |
\end{figure} |
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
data <- cbind(rnorm(100),rnorm(100),rnorm(100)) | |
outlier <- function(xrow){ | |
m <- mean(xrow) | |
devs <- abs(xrow - m) | |
pos <- which.max(devs) | |
val <- devs[pos] | |
out <- c(pos,val) | |
return(out) | |
} |
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
data <- cbind(rnorm(100),rnorm(100),rnorm(100)) | |
outlierMat <- function(mat) { | |
m <- rowMeans(mat) | |
devs <- abs(mat - m) | |
val <- apply(mat, 1, max) | |
pos <- which(mat == val, arr.ind = TRUE) | |
out <- cbind(pos,val) | |
return(out) | |
} |
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(plyr) | |
library(ggplot2) | |
setwd("/.../") | |
data <- read.csv("ft.csv") | |
data.final <- data[data$Amendment == 0,] | |
data.amendment <- data[data$Amendment == 1,] | |
activity <- ddply(data.final,c("Year","Month"),function(x) data.frame(count = length(unique(x$Voteid)))) |
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
from BeautifulSoup import BeautifulSoup | |
import mechanize | |
import time | |
url = "http://www.r-bloggers.com/" | |
br = mechanize.Browser() | |
page = br.open(url) |
OlderNewer