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": "2014-06-11", | |
"y": 20, | |
"group": 1 | |
}, | |
{ | |
"x": "2014-06-12", | |
"y": 25, | |
"group": 1 |
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
#2012 | |
load("C:/120/wptp/sesh1.RData") | |
attach(newdata); | |
with(newdata, plot(I.formed.a.positive.relationship.with.my.tutee.. ~ Semesters)) | |
with(newdata, plot(Semesters ~ Academic.Year)) | |
with(newdata, plot(Are.you.a.section.leader. ~ Academic.Year)) | |
.f = function( | |
lm(Tutor.at.the.same.site ~ My.tutee.benefited.from.tutoring.sessions..) | |
#Intercept: 0.1694 Coeff: 0.1565 |
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
<link rel="import" href="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<link rel="import" href="../core-icons/core-icons.html"> | |
<link rel="import" href="../paper-item/paper-item.html"> |
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
# mlb hall of fame classification analysis | |
# chua@wharton.upenn.edu | |
# attempt to follow https://google-styleguide.googlecode.com/svn/trunk/Rguide.xml | |
rm(list=ls()) | |
par(mfrow=c(1,1)) | |
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load("Lahman", "dplyr", "ggplot2") |
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
# chua@wharton.upenn.edu | |
## my cached version may be slightly different than the live version loaded by this file | |
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load("Lahman", "dplyr") | |
batting <- summarize(group_by(Batting, playerID), | |
ab=sum(AB, na.rm=TRUE), r=sum(R, na.rm=TRUE), | |
h=sum(H, na.rm=TRUE), x2b=sum(X2B, na.rm=TRUE), | |
x3b=sum(X3B, na.rm=TRUE), hr=sum(HR, na.rm=TRUE), |
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
# mlb hall of fame classification analysis | |
# chua@wharton.upenn.edu | |
rm(list = ls()) | |
par(mfrow = c(1, 1)) | |
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load("Lahman", "dplyr", "ggplot2") | |
# get career batting totals |
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
########## | |
#' Applies a function to subsets of a given dataset. | |
#' Note: sets values without sufficient data to NA. | |
#' Using 'step' is particularly useful for leave-one-out analysis. | |
#' | |
#' @export | |
#' @name slide_apply | |
#' @author \href{https://github.com/stillmatic}{Chris Hua} | |
#' @title Use apply over a sliding window of data | |
#' @param data Array of data to apply the function over. |
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
# simple utility function to plot a bunch of graphs in a square-ish fashion | |
findOptArrangement <- function(k) { | |
# k: number of plots to arrange | |
# given k, find most square-like arrangement of the data | |
s <- sqrt(k) | |
f <- floor(s) | |
if(s %% 1 == 0 ) { | |
par(mfrow=c(s,s)) | |
} else { |
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 file was created by CMPT_ME_BEME_RETS_DAILY using the 201602 CRSP database. | |
The Tbill return is the simple daily rate that, over the number of trading days | |
in the month, compounds to 1-month TBill rate from Ibbotson and Associates Inc. | |
Copyright 2016 Kenneth R. French | |
Date Mkt-RF SMB HML RF | |
20060920 0.60 0.59 -0.22 0.020 | |
20060921 -0.59 -0.42 0.12 0.020 | |
20060922 -0.41 -0.85 0.45 0.020 |
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
a <- data.frame("day" = c(1,5,2), "person" = c("A", "B", "C")) | |
b <- data.frame("day" = rep(1:7, 3), "person" = c(rep("A", 7), rep("B", 7), rep("C",7))) | |
b$t0 <- rep(0, nrow(b)) | |
for(i in 1:nrow(a)) { | |
b$t0[which(b$person == a$person[i])] <- a$day[i] | |
} | |
b | |
# this was a stupid thought exercise |
OlderNewer