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
# load data | |
hdata <- read.csv("helpdesk log.csv",header=TRUE,sep=",") | |
hdata$date <- as.Date(hdata$Timestamp,format="%m/%d/%Y") # Timestamp is in mm/dd/YYYY format | |
daycount <- table(hdata$date) # count how many hits per day | |
# daycount is what I call the "short" vector. It misses some days. | |
################################## | |
# daily response wrong graph |
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
# test polynomial interpolation code by interpolating points on a semi-circle | |
# using a different number of points each time. | |
# contents: | |
# 1) make.circle(degree) is a function that generates | |
# n=degree+1 data points (x,y) on a semicircle. this is the "data" we | |
# want to interpolate. | |
# 2) pinterp() makes polynomial interpolation on "data" of degree "degree" | |
# using degree+1 parameters | |
# 3) run() is a wrapper that runs the interpolation |
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
# deferred acceptance algorithm after Gale and Shapley | |
# coded by florian oswald | |
# [email protected] | |
# Deferred Acceptance Algorithm with male offer | |
# accepts your preferences or chooses randomly | |
# to test, use jan's example preferences: | |
# m.prefs = matrix(data=c(1,2,3,4,4,2,3,1,4,3,1,2,1,4,3,2,1,2,4,5),nrow=4) | |
# w.prefs=matrix(data=c(2,3,1,4,5,3,1,2,4,5,5,4,1,2,3,1,4,5,2,3),nrow=5) |
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
# deferred acceptance algorithm after Gale and Shapley | |
# Deferred Acceptance Algorithm with male offer | |
# accepts your preferences or chooses randomly | |
daa <- function(nMen,nWomen,m.prefs=NULL,w.prefs=NULL){ | |
require(animation) # load animation package | |
if (is.null(m.prefs)){ # if no prefs given, make them randomly | |
m.prefs <- replicate(n=nMen,sample(seq(from=1,to=nWomen,by=1))) |
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
#################################### | |
# R code for a CRRA Utility function | |
# Florian Oswald | |
# u(c) is defined over consumption c \in [-\infty,\infty] | |
# has automatic switch to log if CRRA = 1 | |
# can produce diagnostic plot | |
# INPUT: x = vector of consumption values | |
# params = list with 3 entries: CRRA(numeric), cutoff(numeric), diag.plot(bool) | |
# e.g. utility.params <- list('CRRA' = CRRA, 'cutoff' = cutoff, diag.plot=FALSE) | |
# 'cutoff' is a number chosen by the user below which u(c) is quadratically approximated |
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
Creating interactive web graphs with R: Overview and googleVis tutorial | |
======================================== | |
```{r results='asis', echo=FALSE, message=FALSE, tidy=FALSE} | |
library(googleVis) | |
df <- data.frame(Postcode=c("TF3 4JH", "EC1Y 8LX"), | |
Tip=c("Telford", "RSS")) | |
## Tree map | |
T <- gvisTreeMap(Regions, "Region", "Parent", "Val", "Fac", | |
options=list(width=250, height=150, |
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
# R script accompanying quasi-concave, concave etc note | |
if(!require(rgl)) install.packages('rgl') | |
require(rgl) | |
# setup data | |
nx <- 50 # points into x direction | |
ny <- 50 # points into y |
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
#LyX 2.0 created this file. For more info see http://www.lyx.org/ | |
\lyxformat 413 | |
\begin_document | |
\begin_header | |
\textclass article | |
\use_default_options true | |
\begin_modules | |
knitr | |
\end_modules | |
\maintain_unincluded_children false |
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(xlsx) | |
cdat <- read.xlsx(file="~/datasets/ReinhardRogoff/18_data.xls",sheetName="Aut.Ita.UK.US") | |
cdat <- cdat[,-c(5,6,7)] | |
library(reshape) | |
library(ggplot2) | |
m <- melt(cdat,c("Year","Country")) | |
p <- ggplot(m,aes(x=Year,y=value)) + geom_line(aes(color=variable),size=1) + facet_wrap(~Country,ncol=1) + scale_y_continuous(name="Public (Public and Private) debt to GDP (GNP) ratios") + theme(legend.position="top") |
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(inline) | |
library(Rcpp) | |
cpp <- 'arma::mat A = Rcpp::as<arma::mat>(X_); | |
arma::vec y(A.n_rows); | |
arma::rowvec tmp(A.n_cols); | |
for (int i=0; i<A.n_rows; i++) { | |
tmp = A.row(i); | |
y(i) = tmp.max(); | |
} |
OlderNewer