Skip to content

Instantly share code, notes, and snippets.

Anthony Damico ajdamico

Block or report user

Report or block ajdamico

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View La_rs_bughunt.R
# # # # # # # # # # # # # # # # #
# # set the working directory # #
# # # # # # # # # # # # # # # # #
# setwd( "C:/My Directory/SWMAP/" )
# # # # # # # # # # # # # # # #
# # example survey data set # #
# # # # # # # # # # # # # # # #
@ajdamico
ajdamico / puma of my childhood.R
Created Jan 20, 2013
the puma of my childhood
View puma of my childhood.R
# install mapping packages
install.packages( c( 'sp' , 'rgdal' ) )
# load necessary libraries
require(sp)
require(rgdal)
# create a temporary file and directory
tf <- tempfile() ; td <- tempdir()
@ajdamico
ajdamico / rare events in survey sampling.R
Last active Nov 29, 2015
survey research does a lousy job of estimating prevalence rates for unlikely events
View rare events in survey sampling.R
xl <- seq( 0 , 10000 , 100 )
my_title <- 'if we randomly choose X people from some population and determine that none have a disease,\nwe can be 95% confident that the population prevalence rate is below Y% for this particular affliction.'
plot( xl , qbeta(1 - 0.05, 1 , xl ) , ylim=c(0,.01),axes=F,xlab="",ylab="",main="\nhow rare is a rare disease?\n\nsurvey research does a lousy job of estimating prevalence rates for unlikely events")
axis(2, at=seq(0,.01,.001), lab=paste0(seq(0,.01,.001)*100,"%"), las=TRUE)
axis(1, at=seq(0,10000,1000), lab=prettyNum(seq(0,10000,1000),big.mark=","), las=TRUE)
text( 3500 , 0.0075 , label = my_title , cex = 1.5, adj=c(0,0))
z <- data.frame( x = 0:100000 , y = qbeta(1 - 0.05, 1 , 0:100000 ) )
@ajdamico
ajdamico / nona.R
Created Jun 28, 2012
binary operators that never return missing values - how to remove NA values from logical tests
View nona.R
#create the remove NA function
no.na <-
function( x , value = FALSE ){
x[ is.na( x ) ] <- value
x
}
@ajdamico
ajdamico / most recent 100 books posted to paperbackswap.R
Created May 5, 2012
webscrape the ISBN-10 values of the 100 most recent books posted to paperbackswap.com
View most recent 100 books posted to paperbackswap.R
library(XML)
url <- "http://www.paperbackswap.com/api/v1/index.php?RequestType=RecentlyPosted&Limit=100"
u <- xmlParse( url )
v <- getNodeSet( u , "/Response/Books/Book/ISBN-10" )
w <- sapply( v , xmlValue )
@ajdamico
ajdamico / let it be.R
Created Mar 6, 2012
let R sing the beatles
View let it be.R
title = "Let it be"
wow = "words of wisdom"
Verse.1 =
c( "When I find myself in times of trouble" ,
"Mother Mary comes to me" ,
paste( "Speaking" , wow ) ,
title )
@ajdamico
ajdamico / listlabeling.R
Created Oct 31, 2011
roger peng's listlabeling challenge
View listlabeling.R
#roger peng's listlabeling challenge from
#http://simplystatistics.tumblr.com/post/11988685443/computing-on-the-language
#create three example variables for a list
x <- 1
y <- 2
z <- "hello"
#create the function
makeList <- function(...) {
@ajdamico
ajdamico / NHIS download matrix.R
Created Sep 30, 2011
download every file for every year of the National Health Interview Survey and convert them all to csv and stata files
View NHIS download matrix.R
#load necessary libraries
library(stringr)
library(foreign)
library(survey)
library(RCurl)
#set the temporary directory to download all files to!
setwd("s:/temp")
@ajdamico
ajdamico / download all files from an FTP site.R
Created Sep 19, 2011
download fifty years of National Health Interview Survey documentation PDFs
View download all files from an FTP site.R
#install RCurl on your version of R if you don't already have it
#just run this once
#install.packages("RCurl")
#program start
#load the RCurl package
library(RCurl)
#set your output folder - this is where the pdfs will get saved
setwd("R:/National Health Interview Survey/documentation")
@ajdamico
ajdamico / analyzing big survey data with limited computing resources.R
Created Aug 18, 2011
Convert large government survey data files into a SQLite database and then produce the principle set of statistical estimates and accompanying error terms, with limited RAM.
View analyzing big survey data with limited computing resources.R
########################################
###read large csv into SQL DB
########################################
#set to the number of GB of RAM on computer
gbram <- 0.5
#set to CSV file directory
setwd("C:\\American Community Survey\\2009\\")
You can’t perform that action at this time.