Permalink
Browse files

RCurl removal downloader addition setwd and other cleanup

  • Loading branch information...
1 parent c6544bc commit d77350dea7944ae42f938372332159774aeb7fd0 @ajdamico committed Feb 12, 2013
Showing with 228 additions and 283 deletions.
  1. +5 −20 American Community Survey/2005-2011 - download all microdata.R
  2. +3 −1 Area Resource File/2011-2012 arf - analysis examples.R
  3. +10 −21 Area Resource File/2011-2012 arf - download.R
  4. +1 −1 Basic Stand Alone Medicare Claims Public Use Files/2008 - download all csv files.R
  5. +5 −19 Basic Stand Alone Medicare Claims Public Use Files/2008 - import all csv files into monetdb.R
  6. +6 −19 Behavioral Risk Factor Surveillance System/1984 - 2011 download all microdata.R
  7. BIN ...actor Surveillance System/WEAT 2010 Alcohol Consumption by Gender - Crosstab Analysis Results.pdf
  8. +5 −2 Consumer Expenditure Survey/2010-2011 - download all microdata.R
  9. +7 −19 Consumer Expenditure Survey/2011 fmly intrvw - analysis examples.R
  10. +3 −1 Consumer Expenditure Survey/replicate integrated mean and se.R
  11. +8 −19 Current Population Survey/2005-2012 asec - download all microdata.R
  12. +4 −1 Current Population Survey/2012 asec - analysis examples.R
  13. +4 −1 Current Population Survey/replicate census estimates - 2011.R
  14. +4 −1 General Social Survey/1972-2010 cumulative cross-sectional - analysis examples.R
  15. +4 −1 General Social Survey/replicate berkeley sda.R
  16. +4 −1 Health Professional Shortage Areas/download current hpsa table.R
  17. +4 −1 Health Professional Shortage Areas/identify point-in-time geographic hpsas.R
  18. +4 −1 Health Professional Shortage Areas/replicate hrsa nationwide statistics.R
  19. +4 −1 Health and Retirement Study/1992 - 2010 download HRS microdata.R
  20. +7 −4 Health and Retirement Study/import example HRS file.R
  21. +4 −1 Health and Retirement Study/import longitudinal RAND contributed files.R
  22. +4 −1 Health and Retirement Study/longitudinal RAND - analysis examples.R
  23. +4 −1 Health and Retirement Study/replicate 2002 regression.R
  24. +5 −2 Medical Expenditure Panel Survey/1996-2010 household component - download all microdata.R
  25. +4 −1 Medical Expenditure Panel Survey/2010 consolidated - analyze with brr.R
  26. +4 −1 Medical Expenditure Panel Survey/2010 consolidated - analyze with tsl.R
  27. +2 −16 MonetDB/monetdb database creation instructions.R
  28. +1 −1 MonetDB/monetdb installation instructions.R
  29. +3 −1 National Health Interview Survey/2011 personsx - analyze.R
  30. +4 −1 National Health Interview Survey/2011 personsx plus samadult with multiple imputation - analyze.R
  31. +3 −1 National Health Interview Survey/replicate cdc tecdoc - 2000 multiple imputation.R
  32. +4 −1 National Health and Nutrition Examination Survey/2009-2010 interview only - download and analyze.R
  33. +4 −1 ...lth and Nutrition Examination Survey/2009-2010 interview plus laboratory - download and analyze.R
  34. +4 −1 ... Health and Nutrition Examination Survey/replicate 2005-2008 pooled cdc oral examination figure.R
  35. +4 −1 National Health and Nutrition Examination Survey/replicate cdc publications.R
  36. +5 −2 National Survey on Drug Use and Health/1979-2011 - download all microdata.R
  37. +4 −1 National Survey on Drug Use and Health/2010 single-year - analysis examples.R
  38. +4 −1 National Survey on Drug Use and Health/replicate samhsa puf.R
  39. +4 −1 Survey of Consumer Finances/1989-2010 download all microdata.R
  40. +7 −18 Survey of Consumer Finances/2010 analysis examples.R
  41. +7 −18 Survey of Consumer Finances/replicate FRB SAS output.R
  42. +8 −17 Survey of Income and Program Participation/1996 panel - download and create database.R
  43. +8 −17 Survey of Income and Program Participation/2001 panel - download and create database.R
  44. +8 −18 Survey of Income and Program Participation/2004 panel - download and create database.R
  45. +11 −21 Survey of Income and Program Participation/2008 panel - download and create database.R
  46. +4 −1 Survey of Income and Program Participation/2008 panel - full year analysis examples.R
  47. +4 −1 Survey of Income and Program Participation/2008 panel - median value of household assets.R
  48. +4 −1 Survey of Income and Program Participation/2008 panel - point-in-time analysis examples.R
  49. +4 −1 Survey of Income and Program Participation/replicate census poverty statistics.R
View
25 American Community Survey/2005-2011 - download all microdata.R
@@ -50,9 +50,9 @@
# it's running. don't believe me? check the working directory (set below) for a new r data file (.rda) every few hours.
-
+require(downloader) # downloads and then runs the source() function on scripts from github
require(sqlsurvey) # load sqlsurvey package (analyzes large complex design surveys)
-require(RMonetDB) # load the RMonetDB package (connects r to a monet database)
+require(RMonetDB) # load the RMonetDB package (connects r to a monet database)
# set your ACS data directory
@@ -64,25 +64,10 @@ require(RMonetDB) # load the RMonetDB package (connects r to a monet database)
setwd( "C:/My Directory/ACS/" )
-
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
# load the windows.monetdb.configuration() function,
# which allows the easy creation of an executable (.bat) file
# to run the monetdb server specific to this data
-source_https( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/windows.monetdb.configuration.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/windows.monetdb.configuration.R" )
# create a folder "MonetDB" in your current working directory.
@@ -666,9 +651,9 @@ db <- dbConnect( drv , monet.url , user = "monetdb" , password = "monetdb" )
# unlike most post-importation scripts, the monetdb directory cannot be set to read-only #
-winDialog( 'ok' , paste( "all done. DO NOT set" , getwd() , "read-only or subsequent scripts will not work." ) )
+message( paste( "all done. DO NOT set" , getwd() , "read-only or subsequent scripts will not work." ) )
-winDialog( 'ok' , "got that? monetdb directories should not be set read-only." )
+message( "got that? monetdb directories should not be set read-only." )
# for more details on how to work with data in r
View
4 Area Resource File/2011-2012 arf - analysis examples.R
@@ -35,7 +35,9 @@
# after running the program described above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/ARF/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/ARF/" )
+# ..in order to set your current working directory
# load the 2011-2012 ARF data file
View
31 Area Resource File/2011-2012 arf - download.R
@@ -28,11 +28,13 @@
# after downloading and importing it.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/ARF/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/ARF/" )
+# ..in order to set your current working directory
# remove the # in order to run this install.packages line only once
-# install.packages( c( 'SAScii' , 'descr' , 'RSQLite' ) )
+# install.packages( c( 'SAScii' , 'descr' , 'RSQLite' , 'downloader' ) )
@@ -44,29 +46,16 @@ setwd( "C:/My Directory/ARF/" )
# # # # # # # # #
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
-# load the read.SAScii.sqlite function (a variant of read.SAScii that creates a database directly)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
-
-
# load necessary libraries
require(RSQLite) # load RSQLite package (creates database files in R)
require(SAScii) # load the SAScii package (imports ascii data with a SAS script)
require(descr) # load the descr package (converts fixed-width files to delimited files)
require(foreign) # load foreign package (converts data files into R)
+require(downloader) # downloads and then runs the source() function on scripts from github
+
+
+# load the read.SAScii.sqlite function (a variant of read.SAScii that creates a database directly)
+source_url( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
# create a temporary database file and another temporary file
@@ -140,7 +129,7 @@ gc()
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
+message( paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
# for more details on how to work with data in r
# check out my two minute tutorial video site
View
2 Basic Stand Alone Medicare Claims Public Use Files/2008 - download all csv files.R
@@ -151,7 +151,7 @@ for ( zf in all.files ){
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
+message( paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
# for more details on how to work with data in r
View
24 ...c Stand Alone Medicare Claims Public Use Files/2008 - import all csv files into monetdb.R
@@ -36,10 +36,10 @@
# remove the # in order to run this install.packages line only once
-# install.packages( c( "RCurl" , "R.utils" ) )
+# install.packages( c( "downloader" , "R.utils" ) )
-require(RCurl) # load RCurl package (downloads files from the web)
+require(downloader) # downloads and then runs the source() function on scripts from github
require(R.utils) # load the R.utils package (counts the number of lines in a file quickly)
require(RMonetDB) # load the RMonetDB package (connects r to a monet database)
@@ -67,24 +67,10 @@ setwd( "C:/My Directory/BSAPUF/" )
year <- 2008
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
# load the windows.monetdb.configuration() function,
# which allows the easy creation of an executable (.bat) file
# to run the monetdb server specific to this data
-source_https( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/windows.monetdb.configuration.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/windows.monetdb.configuration.R" )
# create a folder "MonetDB" in your current working directory.
@@ -385,9 +371,9 @@ db <- dbConnect( drv , monet.url , user = "monetdb" , password = "monetdb" )
# unlike most post-importation scripts, the monetdb directory cannot be set to read-only #
-winDialog( 'ok' , paste( "all done. DO NOT set" , getwd() , "read-only or subsequent scripts will not work." ) )
+message( paste( "all done. DO NOT set" , getwd() , "read-only or subsequent scripts will not work." ) )
-winDialog( 'ok' , "got that? monetdb directories should not be set read-only." )
+message( "got that? monetdb directories should not be set read-only." )
# don't worry, you won't update any of these tables so long as you exclusively stick with the dbGetQuery() function
# instead of the dbSendUpdate() function (you'll see examples in the analysis scripts)
View
25 Behavioral Risk Factor Surveillance System/1984 - 2011 download all microdata.R
@@ -52,8 +52,9 @@
require(sqlsurvey) # load sqlsurvey package (analyzes large complex design surveys)
-require(RMonetDB) # load the RMonetDB package (connects r to a monet database)
+require(RMonetDB) # load the RMonetDB package (connects r to a monet database)
require(foreign) # load foreign package (converts data files into R)
+require(downloader) # downloads and then runs the source() function on scripts from github
# set your BRFSS data directory
# after downloading and importing
@@ -65,29 +66,15 @@ setwd( "C:/My Directory/BRFSS/" )
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
# load the windows.monetdb.configuration() function,
# which allows the easy creation of an executable (.bat) file
# to run the monetdb server specific to this data
-source_https( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/windows.monetdb.configuration.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/windows.monetdb.configuration.R" )
# load the read.SAScii.monetdb() function,
# which imports ASCII (fixed-width) data files directly into a monet database
# using only a SAS importation script
-source_https( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/read.SAScii.monetdb.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/read.SAScii.monetdb.R" )
# create a folder "MonetDB" in your current working directory.
@@ -540,9 +527,9 @@ db <- dbConnect( drv , monet.url , user = "monetdb" , password = "monetdb" )
# unlike most post-importation scripts, the monetdb directory cannot be set to read-only #
-winDialog( 'ok' , paste( "all done. DO NOT set" , getwd() , "read-only or subsequent scripts will not work." ) )
+message( paste( "all done. DO NOT set" , getwd() , "read-only or subsequent scripts will not work." ) )
-winDialog( 'ok' , "got that? monetdb directories should not be set read-only." )
+message( "got that? monetdb directories should not be set read-only." )
# for more details on how to work with data in r
View
BIN ...rveillance System/WEAT 2010 Alcohol Consumption by Gender - Crosstab Analysis Results.pdf
Binary file not shown.
View
7 Consumer Expenditure Survey/2010-2011 - download all microdata.R
@@ -28,7 +28,10 @@
# after downloading and importing it.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/CES/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/CES/" )
+# ..in order to set your current working directory
+
require(foreign) # load foreign package (converts data files into R)
@@ -166,7 +169,7 @@ for ( year in years.to.download ){
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
+message( paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
# for more details on how to work with data in r
# check out my two minute tutorial video site
View
26 Consumer Expenditure Survey/2011 fmly intrvw - analysis examples.R
@@ -46,7 +46,10 @@
# then the working directory should be set to "C:/My Directory/CES/"
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/CES/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/CES/" )
+# ..in order to set your current working directory
+
# turn off scientific notation in most output
@@ -55,34 +58,19 @@ options( scipen = 20 )
# remove the # in order to run this install.packages line only once
-# install.packages( c( "RSQLite" , "mitools" , "stringr" , "plyr" , "survey" , "RCurl" ) )
+# install.packages( c( "RSQLite" , "mitools" , "stringr" , "plyr" , "survey" , "downloader" ) )
require(RSQLite) # load RSQLite package (creates database files in R)
require(mitools) # allows analysis of multiply-imputed survey data
require(stringr) # load stringr package (manipulates character strings easily)
require(plyr) # contains the rbind.fill() function, which stacks two data frames even if they don't contain the same columns. the rbind() function does not do this
require(survey) # load survey package (analyzes complex design surveys)
-require(RCurl) # load RCurl package (downloads files from the web)
-
-
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
+require(downloader) # downloads and then runs the source() function on scripts from github
# load two svyttest functions (one to conduct a df-adjusted t-test and one to conduct a multiply-imputed t-test)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/Consumer%20Expenditure%20Survey/ces.svyttest.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/Consumer%20Expenditure%20Survey/ces.svyttest.R" )
# now that these two functions have been loaded into r, you can view their source code by uncommenting the two lines below
# svyttest.df
# svyttest.mi
View
4 Consumer Expenditure Survey/replicate integrated mean and se.R
@@ -48,7 +48,9 @@
# then the working directory should be set to "C:/My Directory/CES/"
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/CES/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/CES/" )
+# ..in order to set your current working directory
# turn off scientific notation in most output
View
27 Current Population Survey/2005-2012 asec - download all microdata.R
@@ -28,11 +28,14 @@
# after downloading and importing them.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/CPS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/CPS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
-# install.packages( c( "survey" , "RSQLite" , "SAScii" , "descr" , "RCurl" ) )
+# install.packages( c( "survey" , "RSQLite" , "SAScii" , "descr" , "downloader" ) )
# define which years to download #
@@ -61,30 +64,16 @@ cps.dbname <- "cps.asec.db"
# if the cps database file already exists in the current working directory, print a warning
if ( file.exists( paste( getwd() , cps.dbname , sep = "/" ) ) ) warning( "the database file already exists in your working directory.\nyou might encounter an error if you are running the same year as before or did not allow the program to complete.\ntry changing the cps.dbname in the settings above." )
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
require(RSQLite) # load RSQLite package (creates database files in R)
require(survey) # load survey package (analyzes complex design surveys)
require(SAScii) # load the SAScii package (imports ascii data with a SAS script)
require(descr) # load the descr package (converts fixed-width files to delimited files)
-require(RCurl) # load RCurl package (downloads files from the web)
+require(downloader) # downloads and then runs the source() function on scripts from github
# load the read.SAScii.sqlite function (a variant of read.SAScii that creates a database directly)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
# set R to produce conservative standard errors instead of crashing
@@ -419,7 +408,7 @@ for ( year in cps.years.to.download ){
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste0( "all done. you should set the file " , file.path( getwd() , cps.dbname ) , " read-only so you don't accidentally alter these tables." ) )
+message( paste0( "all done. you should set the file " , file.path( getwd() , cps.dbname ) , " read-only so you don't accidentally alter these tables." ) )
# for more details on how to work with data in r
View
5 Current Population Survey/2012 asec - analysis examples.R
@@ -45,7 +45,10 @@
# after running the program described above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/CPS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/CPS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
5 Current Population Survey/replicate census estimates - 2011.R
@@ -46,7 +46,10 @@
# after running the program described above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/CPS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/CPS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
5 General Social Survey/1972-2010 cumulative cross-sectional - analysis examples.R
@@ -27,7 +27,10 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/GSS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/GSS/" )
+# ..in order to set your current working directory
+
# set the number of digits shown in all output
View
5 General Social Survey/replicate berkeley sda.R
@@ -44,7 +44,10 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/GSS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/GSS/" )
+# ..in order to set your current working directory
+
# set the number of digits shown in all output
View
5 Health Professional Shortage Areas/download current hpsa table.R
@@ -29,7 +29,10 @@
# after downloading and importing it.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/HPSA/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/HPSA/" )
+# ..in order to set your current working directory
+
View
5 Health Professional Shortage Areas/identify point-in-time geographic hpsas.R
@@ -57,7 +57,10 @@
# after downloading and importing it.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/HPSA/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/HPSA/" )
+# ..in order to set your current working directory
+
View
5 Health Professional Shortage Areas/replicate hrsa nationwide statistics.R
@@ -48,7 +48,10 @@
# after downloading and importing it.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/HPSA/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/HPSA/" )
+# ..in order to set your current working directory
+
# load the primary care physician HPSA file
View
5 Health and Retirement Study/1992 - 2010 download HRS microdata.R
@@ -59,7 +59,10 @@ your.password <- "password"
# after downloading.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/HRS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/HRS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
11 Health and Retirement Study/import example HRS file.R
@@ -38,12 +38,15 @@
# import a single HRS file into R, then save that file as an R data file (.rda) for faster loading later #
##########################################################################################################
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/HRS/" )
+# ..in order to set your current working directory
# filepath to a fixed-width file produced by the university of michigan
-fn <- "C:/My Directory/HRS/download/1992/h92core/h92da/HOUSEHLD.DA"
+fn <- "./download/1992/h92core/h92da/HOUSEHLD.DA"
# filepath to the SAS importation instructions for that fixed-width file
-sas.input <- "C:/My Directory/HRS/download/1992/h92core/h92sas/HOUSEHLD.SAS"
+sas.input <- "./download/1992/h92core/h92sas/HOUSEHLD.SAS"
@@ -126,15 +129,15 @@ head( x )
tail( x )
# finally, save the data frame as a '.rda' file for ultra-fast loading in the future.
-save( x , file = 'C:/My Directory/HRS/household.rda' )
+save( x , file = 'household.rda' )
######################################################
# close and re-open R to see how much faster this is #
######################################################
-load( 'C:/My Directory/HRS/household.rda' )
+load( 'household.rda' )
# count the number of records in x
nrow( x )
View
5 Health and Retirement Study/import longitudinal RAND contributed files.R
@@ -39,7 +39,10 @@
# all HRS data files should have been stored within a download/ folder here
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/HRS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/HRS/" )
+# ..in order to set your current working directory
+
# choose the name of the database
db.name <- 'RAND.db'
View
5 Health and Retirement Study/longitudinal RAND - analysis examples.R
@@ -35,7 +35,10 @@
# the SQLite database file should have been stored within this folder
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/HRS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/HRS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
# install.packages( "survey" )
View
5 Health and Retirement Study/replicate 2002 regression.R
@@ -47,7 +47,10 @@
# the SQLite database file should have been stored within this folder
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/HRS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/HRS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
# install.packages( "survey" )
View
7 Medical Expenditure Panel Survey/1996-2010 household component - download all microdata.R
@@ -28,7 +28,10 @@
# after downloading.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/MEPS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/MEPS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
@@ -370,7 +373,7 @@ for ( i in nrow( mm ):1 ) {
}
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
+message( paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
# for more details on how to work with data in r
View
5 Medical Expenditure Panel Survey/2010 consolidated - analyze with brr.R
@@ -66,7 +66,10 @@
# created by the R program specified above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/MEPS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/MEPS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
5 Medical Expenditure Panel Survey/2010 consolidated - analyze with tsl.R
@@ -66,7 +66,10 @@
# created by the R program specified above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/MEPS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/MEPS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
18 MonetDB/monetdb database creation instructions.R
@@ -14,28 +14,14 @@
# if you've successfully installed monetdb to your machine,
# you should be able to initiate your first database with these commands:
-
+require(downloader) # downloads and then runs the source() function on scripts from github
require(RMonetDB) # load the RMonetDB package (connects r to a monet database)
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
# load the windows.monetdb.configuration() function,
# which allows the easy creation of an executable (.bat) file
# to run the monetdb server specific to this data
-source_https( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/windows.monetdb.configuration.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/MonetDB/windows.monetdb.configuration.R" )
# run the windows.monetdb.configuration() function to
View
2 MonetDB/monetdb installation instructions.R
@@ -32,4 +32,4 @@
# open up your R console and run these two separate installation commands without the # sign in front:
# install.packages("RMonetDB" , repos = c( "http://cran.r-project.org" , "http://R-Forge.R-project.org" ) , dep=TRUE )
# install.packages("sqlsurvey" , repos = c( "http://cran.r-project.org" , "http://R-Forge.R-project.org" ) , dep=TRUE )
-# install.packages( c( 'SAScii' , 'descr' , 'survey' , 'RCurl' ) )
+# install.packages( c( 'SAScii' , 'descr' , 'survey' , 'downloader' ) )
View
4 National Health Interview Survey/2011 personsx - analyze.R
@@ -43,7 +43,9 @@
# then the working directory should be set to "C:/My Directory/NHIS/"
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NHIS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NHIS/" )
+# ..in order to set your current working directory
# remove the # in order to run this install.packages line only once
View
5 ... Health Interview Survey/2011 personsx plus samadult with multiple imputation - analyze.R
@@ -43,7 +43,10 @@
# then the working directory should be set to "C:/My Directory/NHIS/"
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NHIS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NHIS/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
4 National Health Interview Survey/replicate cdc tecdoc - 2000 multiple imputation.R
@@ -34,7 +34,9 @@
# will be stored here after downloading and importing them.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NHIS/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NHIS/" )
+# ..in order to set your current working directory
# remove the # in order to run this install.packages line only once
View
5 ...Health and Nutrition Examination Survey/2009-2010 interview only - download and analyze.R
@@ -26,7 +26,10 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NHANES/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NHANES/" )
+# ..in order to set your current working directory
+
# set the number of digits shown in all output
View
5 ...Nutrition Examination Survey/2009-2010 interview plus laboratory - download and analyze.R
@@ -32,7 +32,10 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NHANES/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NHANES/" )
+# ..in order to set your current working directory
+
# set the number of digits shown in all output
View
5 ...and Nutrition Examination Survey/replicate 2005-2008 pooled cdc oral examination figure.R
@@ -34,7 +34,10 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NHANES/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NHANES/" )
+# ..in order to set your current working directory
+
# set the number of digits shown in all output
View
5 National Health and Nutrition Examination Survey/replicate cdc publications.R
@@ -60,7 +60,10 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NHANES/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NHANES/" )
+# ..in order to set your current working directory
+
# set the number of digits shown in all output
View
7 National Survey on Drug Use and Health/1979-2011 - download all microdata.R
@@ -54,7 +54,10 @@
# after downloading and importing it.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NSDUH/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NSDUH/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
@@ -284,7 +287,7 @@ for ( i in rev( seq( nrow( studies.by.year ) ) ) ){
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
+message( paste( "all done. you should set" , getwd() , "read-only so you don't accidentally alter these files." ) )
# for more details on how to work with data in r
View
5 National Survey on Drug Use and Health/2010 single-year - analysis examples.R
@@ -41,7 +41,10 @@
# then the working directory should be set to "C:/My Directory/NSDUH/"
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NSDUH/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NSDUH/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
5 National Survey on Drug Use and Health/replicate samhsa puf.R
@@ -54,7 +54,10 @@
# then the working directory should be set to "C:/My Directory/NSDUH/"
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/NSDUH/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/NSDUH/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
5 Survey of Consumer Finances/1989-2010 download all microdata.R
@@ -41,7 +41,10 @@ years.to.download <- c( 1989 , 1992 , 1995 , 1998 , 2001 , 2004 , 2007 , 2009 ,
# after downloading.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SCF/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SCF/" )
+# ..in order to set your current working directory
+
# no need to edit anything below this line #
View
25 Survey of Consumer Finances/2010 analysis examples.R
@@ -34,16 +34,19 @@
# set your working directory.
# the SCF 2010 R data file (scf2010.rda) should have been stored in this folder.
-setwd( "C:/My Directory/SCF/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SCF/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
-# install.packages( c( 'mitools' , 'survey' , 'RCurl' ) )
+# install.packages( c( 'mitools' , 'survey' , 'downloader' ) )
require(mitools) # allows analysis of multiply-imputed survey data
require(survey) # load survey package (analyzes complex design surveys)
-require(RCurl) # load RCurl package (downloads files from the web)
+require(downloader) # downloads and then runs the source() function on scripts from github
require(foreign) # load foreign package (converts data files into R)
@@ -82,23 +85,9 @@ gc()
# turn off scientific notation in most output
options( scipen = 20 )
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
# load two svyttest functions (one to conduct a df-adjusted t-test and one to conduct a multiply-imputed t-test)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/Survey%20of%20Consumer%20Finances/scf.survey.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/Survey%20of%20Consumer%20Finances/scf.survey.R" )
# now that this function has been loaded into r, you can view its source code by uncommenting the line below
# scf.MIcombine
# scf.svyttest
View
25 Survey of Consumer Finances/replicate FRB SAS output.R
@@ -56,16 +56,19 @@
# set your working directory.
# the SCF 2010 R data file (scf2010.rda) should have been stored in this folder.
-setwd( "C:/My Directory/SCF/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SCF/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
-# install.packages( c( 'mitools' , 'survey' , 'Hmisc' , 'RCurl' ) )
+# install.packages( c( 'mitools' , 'survey' , 'Hmisc' , 'downloader' ) )
require(mitools) # allows analysis of multiply-imputed survey data
require(survey) # load survey package (analyzes complex design surveys)
-require(RCurl) # load RCurl package (downloads files from the web)
+require(downloader) # downloads and then runs the source() function on scripts from github
require(foreign) # load foreign package (converts data files into R)
require(Hmisc) # load Hmisc package (loads a simple wtd.quantile function)
@@ -106,23 +109,9 @@ gc()
# turn off scientific notation in most output
options( scipen = 20 )
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
# load two svyttest functions (one to conduct a df-adjusted t-test and one to conduct a multiply-imputed t-test)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/Survey%20of%20Consumer%20Finances/scf.survey.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/Survey%20of%20Consumer%20Finances/scf.survey.R" )
# now that this function has been loaded into r, you can view its source code by uncommenting the line below
# scf.MIcombine
# scf.svyttest
View
25 Survey of Income and Program Participation/1996 panel - download and create database.R
@@ -29,11 +29,14 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SIPP/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SIPP/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
-# install.packages( c( "RSQLite" , "SAScii" , "descr" ) )
+# install.packages( c( "RSQLite" , "SAScii" , "descr" , "downloader" ) )
SIPP.dbname <- "SIPP96.db" # choose the name of the database (.db) file on the local disk
@@ -55,6 +58,7 @@ sipp.pnl.longitudinal.replicate.weights <- 'pnl' # set to NULL to prevent do
require(RSQLite) # load RSQLite package (creates database files in R)
require(SAScii) # load the SAScii package (imports ascii data with a SAS script)
+require(downloader) # downloads and then runs the source() function on scripts from github
# open the connection to the sqlite database
@@ -151,22 +155,9 @@ fix.repwgt <-
}
##################################################################################
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
# load the read.SAScii.sqlite function (a variant of read.SAScii that creates a database directly)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
# set the locations of the data files on the ftp site
SIPP.core.sas <-
@@ -316,7 +307,7 @@ dbDisconnect( db )
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste0( "all done. you should set the file " , file.path( getwd() , SIPP.dbname ) , " read-only so you don't accidentally alter these tables." ) )
+message( paste0( "all done. you should set the file " , file.path( getwd() , SIPP.dbname ) , " read-only so you don't accidentally alter these tables." ) )
# for more details on how to work with data in r
View
25 Survey of Income and Program Participation/2001 panel - download and create database.R
@@ -30,11 +30,14 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SIPP/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SIPP/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
-# install.packages( c( "RSQLite" , "SAScii" , "descr" ) )
+# install.packages( c( "RSQLite" , "SAScii" , "descr" , "downloader" ) )
SIPP.dbname <- "SIPP01.db" # choose the name of the database (.db) file on the local disk
@@ -58,6 +61,7 @@ sipp.pnl.longitudinal.replicate.weights <- paste0( 'pnl' , 1:3 ) # 1-3 reads in
require(RSQLite) # load RSQLite package (creates database files in R)
require(SAScii) # load the SAScii package (imports ascii data with a SAS script)
+require(downloader) # downloads and then runs the source() function on scripts from github
# open the connection to the sqlite database
@@ -88,22 +92,9 @@ fix.ct <-
}
##############################################################################
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
# load the read.SAScii.sqlite function (a variant of read.SAScii that creates a database directly)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
# set the locations of the data files on the ftp site
SIPP.core.sas <-
@@ -301,7 +292,7 @@ dbDisconnect( db )
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste0( "all done. you should set the file " , file.path( getwd() , SIPP.dbname ) , " read-only so you don't accidentally alter these tables." ) )
+message( paste0( "all done. you should set the file " , file.path( getwd() , SIPP.dbname ) , " read-only so you don't accidentally alter these tables." ) )
# for more details on how to work with data in r
View
26 Survey of Income and Program Participation/2004 panel - download and create database.R
@@ -29,11 +29,14 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SIPP/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SIPP/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
-# install.packages( c( "RSQLite" , "SAScii" , "descr" ) )
+# install.packages( c( "RSQLite" , "SAScii" , "descr" , "downloader" ) )
SIPP.dbname <- "SIPP04.db" # choose the name of the database (.db) file on the local disk
@@ -55,7 +58,7 @@ sipp.pnl.longitudinal.replicate.weights <- paste0( 'pnl' , 1:4 ) # 1-4 reads in
require(RSQLite) # load RSQLite package (creates database files in R)
require(SAScii) # load the SAScii package (imports ascii data with a SAS script)
-
+require(downloader) # downloads and then runs the source() function on scripts from github
# open the connection to the sqlite database
db <- dbConnect( SQLite() , SIPP.dbname )
@@ -85,22 +88,9 @@ fix.ct <-
}
##############################################################################
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
# load the read.SAScii.sqlite function (a variant of read.SAScii that creates a database directly)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
# set the locations of the data files on the ftp site
SIPP.core.sas <-
@@ -223,7 +213,7 @@ dbDisconnect( db )
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste0( "all done. you should set the file " , file.path( getwd() , SIPP.dbname ) , " read-only so you don't accidentally alter these tables." ) )
+message( paste0( "all done. you should set the file " , file.path( getwd() , SIPP.dbname ) , " read-only so you don't accidentally alter these tables." ) )
# for more details on how to work with data in r
View
32 Survey of Income and Program Participation/2008 panel - download and create database.R
@@ -1,7 +1,7 @@
# analyze us government survey data with the r language
# survey of income and program participation
# 2008 panel
-# 11 core waves, 10 wave-specific replicate weights, 9 topical modules,
+# 11 core waves, 11 wave-specific replicate weights, 9 topical modules,
# 2 panel year replicate weights, 2 calendar year replicate weights, 1 longitudinal weights
# if you have never used the r language before,
@@ -29,17 +29,20 @@
# after downloading and importing.
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SIPP/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SIPP/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
-# install.packages( c( "RSQLite" , "SAScii" , "descr" ) )
+# install.packages( c( "RSQLite" , "SAScii" , "descr" , "downloader" ) )
SIPP.dbname <- "SIPP08.db" # choose the name of the database (.db) file on the local disk
-sipp.core.waves <- 1:11 # either choose which core survey waves to download, or set to null
-sipp.replicate.waves <- 1:10 # either choose which replicate weight waves to download, or set to null
+sipp.core.waves <- 1:11 # either choose which core survey waves to download, or set to NULL
+sipp.replicate.waves <- 1:11 # either choose which replicate weight waves to download, or set to NULL
sipp.topical.modules <- 1:9 # either choose which topical modules to download, or set to NULL
sipp.longitudinal.weights <- TRUE # set to FALSE to prevent download
sipp.cy.longitudinal.replicate.weights <- paste0( 'cy' , c( "09" , "10" ) ) # reads in 2009-2010
@@ -55,6 +58,7 @@ sipp.pnl.longitudinal.replicate.weights <- paste0( 'pnl' , c( "09" , "10" ) ) #
require(RSQLite) # load RSQLite package (creates database files in R)
require(SAScii) # load the SAScii package (imports ascii data with a SAS script)
+require(downloader) # downloads and then runs the source() function on scripts from github
# open the connection to the sqlite database
@@ -152,22 +156,8 @@ fix.repwgt <-
##################################################################################
-#######################################################
-# function to download scripts directly from github.com
-# http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
-source_https <- function(url, ...) {
- # load package
- require(RCurl)
-
- # parse and evaluate each .R script
- sapply(c(url, ...), function(u) {
- eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
- })
-}
-#######################################################
-
# load the read.SAScii.sqlite function (a variant of read.SAScii that creates a database directly)
-source_https( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
+source_url( "https://raw.github.com/ajdamico/usgsd/master/SQLite/read.SAScii.sqlite.R" )
# set the locations of the data files on the ftp site
SIPP.core.sas <-
@@ -290,7 +280,7 @@ dbDisconnect( db )
# print a reminder: set the directory you just saved everything to as read-only!
-winDialog( 'ok' , paste0( "all done. you should set the file " , file.path( getwd() , SIPP.dbname ) , " read-only so you don't accidentally alter these tables." ) )
+message( paste0( "all done. you should set the file " , file.path( getwd() , SIPP.dbname ) , " read-only so you don't accidentally alter these tables." ) )
# for more details on how to work with data in r
View
5 Survey of Income and Program Participation/2008 panel - full year analysis examples.R
@@ -35,7 +35,10 @@
# "SIPP08.db" created by the R program specified above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SIPP/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SIPP/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
5 Survey of Income and Program Participation/2008 panel - median value of household assets.R
@@ -35,7 +35,10 @@
# "SIPP08.db" created by the R program specified above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SIPP/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SIPP/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
5 Survey of Income and Program Participation/2008 panel - point-in-time analysis examples.R
@@ -35,7 +35,10 @@
# "SIPP08.db" created by the R program specified above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SIPP/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SIPP/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once
View
5 Survey of Income and Program Participation/replicate census poverty statistics.R
@@ -49,7 +49,10 @@
# "SIPP08.db" created by the R program specified above
# use forward slashes instead of back slashes
-setwd( "C:/My Directory/SIPP/" )
+# uncomment this line by removing the `#` at the front..
+# setwd( "C:/My Directory/SIPP/" )
+# ..in order to set your current working directory
+
# remove the # in order to run this install.packages line only once

0 comments on commit d77350d

Please sign in to comment.