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
N <- 10 | |
id <- 1:10 | |
x <- 1 + rnorm(N) - 1*id | |
date <- seq(as.Date("2013-07-01"), by = "year", along = x) | |
df <- data.frame(x = x, date = date) | |
plot(df$date, df$x) | |
summary(lm(x ~ date, data = df)) | |
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
ANOVA<-function(fit1,fit2){ | |
temp <- anova(fit2,fit1 ) | |
fin.aov <- anova(fit1) | |
reg <- temp[2,2:6] | |
rownames(reg) <- "Regression" | |
reg[1,1:2] <- reg[1,2:3] | |
reg[1,3] <- reg[1,2]/reg[1,1] | |
colnames(reg) <- colnames(fin.aov) | |
res <- fin.aov[tail(nrow(fin.aov),1),] | |
tot <- cbind(reg[1,1:2]+res[1,1:2],NA,NA,NA) |
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
suppressMessages(library(forecast)) | |
data<-read.csv( file('stdin') ) | |
anomaly_detection<-function(data){ | |
seasonality<-48 | |
data_series<-ts(data$count,frequency=seasonality) | |
train_start<-1 ## train on 1 month of data |
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 Loading | |
library("RPostgreSQL"); | |
library("car"); | |
# Connect to Database | |
pgDrv <- dbDriver("PostgreSQL") | |
dbh <- dbConnect(pgDrv, host="localhost", dbname="dnsmonitor", user="dnsmon", password="tooEasy") | |
# Retrieve Statistics from DB | |
stats <- dbGetQuery(dbh, "select client.id, client.ip, sum(queries) as queries, sum(nx) as nx, sum(answers) as answers, sum(errors) as errors, count(distinct day) as days_active |
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
#################### | |
# Create relogit predicted probabilities using Zelig and ggplot2 | |
# Two Sword Lengths: Losers' Consent and Violence in National Legislatures (Working Paper 2012) | |
# Christopher Gandrud | |
# Updated 26 April 2012 | |
################### | |
## Load required packages | |
library(RCurl) | |
library(Zelig) |
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
let vLastMonth = Year(AddMonths(now(),-1)) & '-' & num(month(addmonths(now(),-1)),'00') & '-01'; | |
// This gets the first of the previous month | |
let vThisMonth = Year(now()) & '-' & num(month(now()),'00') & '-01'; | |
// This gets the first of the current month | |
ODBC CONNECT TO MyDSN; // Change to your database | |
LOAD *; | |
SQL SELECT |
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
######################################### | |
## GLOBAL REQUIREMENTS AND DEFINITIONS ## | |
######################################### | |
require(RCurl) | |
require(XML) | |
loginURL <- "https://accounts.google.com/ServiceLogin" | |
authenticateURL <- "https://accounts.google.com/accounts/ServiceLoginAuth" |
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
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
var FORMAT_ONELINE = 'One-line'; | |
var FORMAT_MULTILINE = 'Multi-line'; | |
var FORMAT_PRETTY = 'Pretty'; | |
var LANGUAGE_JS = 'JavaScript'; | |
var LANGUAGE_PYTHON = 'Python'; |
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
/** | |
* Copyright 2010, Boy van Amstel | |
* All rights reserved. | |
*/ | |
var NAME = 'TTResponds'; | |
var CONFIGSHEET = 'TTRespondsConfig'; | |
var _activeApp = SpreadsheetApp.getActive(); | |
var _formSheet = _activeApp.getSheets()[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
set RecCount = 500000000; // Number of records to generate | |
Data: | |
load | |
chr(round(25 * rand() + 65)) & chr(round(25 * rand() + 65)) & chr(round(25 * rand() + 65)) as Customer, // Customer name between AAA and ZZZ | |
chr(round(25 * rand() + 65)) as Product, // Product name between A and Z | |
round(3 * Rand() + 2008) as Year, // Year between 2008 and 2011 | |
round(1000000 * Rand()) as Actual, // Actual Revenue between 0 and 1,000,000 | |
round(1000000 * Rand()) as Target // Target Revenue between 0 and 1,000,000 | |
autogenerate(RecCount); |