Skip to content

Instantly share code, notes, and snippets.

@BioSciEconomist
BioSciEconomist / python basic stats.py
Created February 22, 2017 02:32
Basic Statistics in Python
#------------------------------------------------------------------
# PROGRAM NAME: python basic stats.py
# DATE: 2/20/16
# CREATED BY: MATT BOGARD
# PROJECT FILE:
#----------------------------------------------------------------
# PURPOSE: BASIC STATS IN PYTHON
#---------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / R basic statistics.r
Created February 22, 2017 02:31
Basic Statistics in R
# ------------------------------------------------------------------
# |PROGRAM NAME: R basic statistics
# |DATE: 2/20/17
# |CREATED BY: MATT BOGARD
# |PROJECT FILE:
# |----------------------------------------------------------------
# | PURPOSE: BASIC STATISTICS IN R
# |----------------------------------------------------------------
# create some toy data
@BioSciEconomist
BioSciEconomist / python basic.py
Last active May 18, 2018 20:53
Basic data manipulation in python
#------------------------------------------------------------------
# PROGRAM NAME: Python Examples.py
# DATE: 6/1/16
# CREATED BY: MATT BOGARD
# PROJECT FILE:
#----------------------------------------------------------------
# PURPOSE: BASIC DATA MANAGEMENT AND STATS IN PYTHON
# ---------------------------------------------------------------
#---------------------------------
# ------------------------------------------------------------------
# |PROGRAM NAME: R basic data manipulation
# |DATE: 2/20/17
# |CREATED BY: MATT BOGARD
# |PROJECT FILE:
# |----------------------------------------------------------------
# | PURPOSE: BASIC DATA MANAGEMENT AND STATS IN R
# |----------------------------------------------------------------
# create some toy data
@BioSciEconomist
BioSciEconomist / rbasic.r
Created February 21, 2017 15:35
R basic data manipulation
# ------------------------------------------------------------------
# |PROGRAM NAME: R basic data manipulation
# |DATE: 2/20/17
# |CREATED BY: MATT BOGARD
# |PROJECT FILE:
# |----------------------------------------------------------------
# | PURPOSE: BASIC DATA MANAGEMENT AND STATS IN R
# |----------------------------------------------------------------
@BioSciEconomist
BioSciEconomist / neuralnet.r
Created November 6, 2016 17:23
R Code Example for Neural Networks
# ------------------------------------------------------------------
# |PROGRAM NAME: NEURALNET_PKG_R
# |DATE: 12/3/10
# |CREATED BY: MATT BOGARD
# |PROJECT FILE: http://econometricsense.blogspot.com/2010/12/r-code-example-for-neural-networks.html
# |----------------------------------------------------------------
# | PURPOSE: DEMO OF THE 'neuralnet' PACKAGE AND OUTPUT INTERPRETATION
# |
# | ADAPTED FROM: neuralnet: Training of Neural Networks
# | by Frauke Günther and Stefan Fritsch The R Journal Vol. 2/1, June 2010
@BioSciEconomist
BioSciEconomist / bubble crops.r
Created November 6, 2016 17:22
Visualizing Agricultural Subsidies
# -------------------------------------------------------------
# | PROGRAM NAME: Bubble_Crops
# | DATE: 12-4-2010
# | CREATED BY: Matt Bogard
# | PROJECT FILE: http://econometricsense.blogspot.com/2010/12/visualizing-agricultural-subsidies-by.html
# |-------------------------------------------------------------
# | PURPOSE: Intitially to create bubble charts to demonstrate
# | allocation
# | of farm subsides to producers by KY county, but expanded to
# | include
@BioSciEconomist
BioSciEconomist / google vis.r
Created November 6, 2016 17:20
Google Vis Demo
# ------------------------------------------------------------------
# | PROGRAM NAME: googleVis_R
# | DATE: 1/12/11
# | CREATED BY: Matt Bogard
# | PROJECT FILE:http://econometricsense.blogspot.com/2011/01/r-code-for-googlevis-demo.html
# |----------------------------------------------------------------
# | PURPOSE: Tutorial for creating Motion Charts in R with the GoogleVis package
# |
# |
# |
@BioSciEconomist
BioSciEconomist / density plots.r
Last active November 6, 2016 17:19
Overlapping density plots
### r code to support: http://econometricsense.blogspot.com/2011/01/flexibility-of-r-graphics.html
library(colorspace) # package for rainbow_hcl function
ds <- rbind(data.frame(dat=KyCropsAndSubsidies[,][,"LogAcres"], grp="All"),
data.frame(dat=KyCropsAndSubsidies[,][KyCropsAndSubsidies$subsidy_in_millions > 2.76,"LogAcres"], grp=">median"),
data.frame(dat=KyCropsAndSubsidies[,][KyCropsAndSubsidies$subsidy_in_millions <= 2.76,"LogAcres"], grp="<=median"))
@BioSciEconomist
BioSciEconomist / mutli merge.r
Created November 6, 2016 17:13
Merging multiple date frames in R
### r code to support: http://econometricsense.blogspot.com/2011/01/merging-multiple-data-frames-in-r.html
# read all Y2000 csv files
filenames <- list.files(path="/Users/wkuuser/Desktop/R Data Sets/TRADE_DATA/TempData00", full.names=TRUE)
import.list <- llply(filenames, read.csv)
# left join all Y2000 csv files
AllData00 <- Reduce(function(x, y) merge(x, y, all=FALSE,by.x="Reporting.Countries.Partner.Countries",by.y="Reporting.Countries.Partner.Countries",all.x =TRUE, all.y =FALSE),import.list,accumulate=F)