diff --git a/.Rbuildignore b/.Rbuildignore index 6a643da..6484c3e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,4 @@ ^.*\.Rproj$ ^\.Rproj\.user$ ^data-raw$ +.travis.yml diff --git a/.Rprofile b/.Rprofile deleted file mode 100644 index 22ec147..0000000 --- a/.Rprofile +++ /dev/null @@ -1,3 +0,0 @@ -#### -- Packrat Autoloader (version 0.4.8-1) -- #### -source("packrat/init.R") -#### -- End Packrat Autoloader -- #### diff --git a/.gitignore b/.gitignore index 5405e03..83543c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ packrat/lib*/ +.Rhistory .Rproj.user .DS_Store diff --git a/.travis.yml b/.travis.yml index 8d139ac..fab329d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,4 @@ language: R sudo: false cache: packages +r_build_args: "--resave-data" diff --git a/DESCRIPTION b/DESCRIPTION index 78af9b1..f4b5324 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,12 +3,12 @@ Type: Package Title: Calculating the Scottish Index of Multiple Deprivation Version: 0.1.0 Author: Roman Popat -Maintainer: The package maintainer +Maintainer: The package maintainer Description: Data and functions to calculate the Scottish Index of Multiple Deprivation from 7 different indicator domains. -License: MIT +License: MIT + file LICENSE Encoding: UTF-8 LazyData: true -RoxygenNote: 6.0.1 +RoxygenNote: 6.1.0 Imports: dplyr, psych, diff --git a/NAMESPACE b/NAMESPACE index 5a0095f..d72f25f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,3 +6,6 @@ export(getFAWeights) export(normalScores) export(reassignRank) export(replaceMissing) +import(dplyr) +importFrom(stats,na.omit) +importFrom(stats,qnorm) diff --git a/R/getFAWeights.R b/R/getFAWeights.R index b84a879..8ac49d2 100644 --- a/R/getFAWeights.R +++ b/R/getFAWeights.R @@ -14,12 +14,14 @@ #' #' @keywords SIMD, openSIMD, simdr #' +#' @import dplyr +#' #' @export getFAWeights <- function(dat, ...) { fact <- psych::fa(dat, nfactors = 1, fm = "ml", rotate = "none", ...) - f1_scores <- as.data.frame(fact$weights) %>% select(ML1) + f1_scores <- as.data.frame(fact$weights) %>% select("ML1") f1_weights <- f1_scores / sum(f1_scores) diff --git a/R/normalScores.R b/R/normalScores.R index e3a56da..bfcb051 100644 --- a/R/normalScores.R +++ b/R/normalScores.R @@ -29,6 +29,8 @@ #' # (not run) #' # PUT SOME CODE HERE #' +#' @importFrom stats na.omit qnorm +#' #' @export normalScores <- function( diff --git a/R/sas_weights.R b/R/sas_weights.R index f4b3dbd..676244c 100644 --- a/R/sas_weights.R +++ b/R/sas_weights.R @@ -1,14 +1,59 @@ #' Factor analysis weights derived from SAS #' -#' [describe it here] +#' We include the Factor Analysis weights calculated in SAS from the 2016 SIMD calculations. +#' This is mostly for quality control evaluating the correspondence between the SAS and R methodologies. +#' To see our quality control analysis see [quality assurance section of the openSIMD documentation](https://thedatalabscotland.github.io/openSIMD_site/QA.html) #' #' Please see the technical notes \url{http://www.gov.scot/Resource/0050/00504822.pdf} for full information on all of the data in SIMD. #' -#' @format A data frame with ___ rows and ___ variables: +#' @format A data frame with 1 rows and 43 variables: #' \describe{ -#' \item{variable}{description} -#' \item{}{Count of individuals with no qualifications} -#' \item{}{Normalised count, derived from SIMD proceedure in SAS} +#' +#' \item{n_neet}{} +#' \item{n_noquals}{} +#' \item{n_attain}{} +#' \item{n_attend}{} +#' \item{n_hesa}{} +#' \item{n_cif}{} +#' \item{n_smr}{} +#' \item{n_lbwt}{} +#' \item{n_drug}{} +#' \item{n_alc}{} +#' \item{n_depress}{} +#' \item{n_emerg}{} +#' \item{n_dr_gp}{} +#' \item{n_dr_post}{} +#' \item{n_dr_prim}{} +#' \item{n_dr_sec}{} +#' \item{n_dr_retail}{} +#' \item{n_dr_petrol}{} +#' \item{n_pt_gp}{} +#' \item{n_pt_post}{} +#' \item{n_pt_retail}{} +#' +#' \item{wt_neet}{} +#' \item{wt_noquals}{} +#' \item{wt_attain}{} +#' \item{wt_attend}{} +#' \item{wt_hesa}{} +#' \item{wt_cif}{} +#' \item{wt_smr}{} +#' \item{wt_lbwt}{} +#' \item{wt_drug}{} +#' \item{wt_alc}{} +#' \item{wt_depress}{} +#' \item{wt_emerg}{} +#' \item{wt_dr_gp}{} +#' \item{wt_dr_post}{} +#' \item{wt_dr_prim}{} +#' \item{wt_dr_sec}{} +#' \item{wt_dr_retail}{} +#' \item{wt_dr_petrol}{} +#' \item{wt_pt_gp}{} +#' \item{wt_pt_post}{} +#' \item{wt_pt_retail}{} +#' +#' \item{n}{} #' ... #' } #' @source \url{http://www.gov.scot/Topics/Statistics/SIMD} diff --git a/R/sim16_domains.R b/R/sim16_domains.R index aafb8ec..7c283fe 100644 --- a/R/sim16_domains.R +++ b/R/sim16_domains.R @@ -1,14 +1,25 @@ #' Domain ranks from published SIMD 2016 #' -#' [describe it here] +#' We include the domain ranks from the 2016 SIMD for purposes of evaluating the correspondence between the SAS and R methodologies. +#' To see our quality control analysis see [quality assurance section of the openSIMD documentation](https://thedatalabscotland.github.io/openSIMD_site/QA.html) #' #' Please see the technical notes \url{http://www.gov.scot/Resource/0050/00504822.pdf} for full information on all of the data in SIMD. #' -#' @format A data frame with ___ rows and ___ variables: +#' @format A data frame with 6976 rows and 13 variables: #' \describe{ -#' \item{variable}{description} -#' \item{}{Count of individuals with no qualifications} -#' \item{}{Normalised count, derived from SIMD proceedure in SAS} +#' \item{Data_Zone}{} +#' \item{Intermediate_Zone}{} +#' \item{Council_area}{} +#' \item{Total_population}{} +#' \item{Working_age_population_revised}{} +#' \item{Overall_SIMD16_rank}{} +#' \item{Income_domain_2016_rank}{} +#' \item{Employment_domain_2016_rank}{} +#' \item{Health_domain_2016_rank}{} +#' \item{Education_domain_2016_rank}{} +#' \item{Housing_domain_2016_rank}{} +#' \item{Access_domain_2016_rank}{} +#' \item{Crime_domain_2016_rank}{} #' ... #' } #' @source \url{http://www.gov.scot/Topics/Statistics/SIMD} diff --git a/R/simd16_indicators.R b/R/simd16_indicators.R index aa7b62e..bc195be 100644 --- a/R/simd16_indicators.R +++ b/R/simd16_indicators.R @@ -1,14 +1,48 @@ #' Indicator data from published SIMD 2016 #' -#' [describe it here] +#' We include the indicator data from the 2016 SIMD for purposes of evaluating the correspondence between the SAS and R methodologies. +#' To see our quality control analysis see [quality assurance section of the openSIMD documentation](https://thedatalabscotland.github.io/openSIMD_site/QA.html) #' #' Please see the technical notes \url{http://www.gov.scot/Resource/0050/00504822.pdf} for full information on all of the data in SIMD. #' -#' @format A data frame with ___ rows and ___ variables: +#' @format A data frame with 6976 rows and 36 variables: #' \describe{ -#' \item{variable}{description} -#' \item{}{Count of individuals with no qualifications} -#' \item{}{Normalised count, derived from SIMD proceedure in SAS} +#' \item{Data_Zone}{description} +#' \item{Intermediate_Zone}{description} +#' \item{Council_area}{description} +#' \item{Total_population}{description} +#' \item{Working_age_population_revised}{description} +#' \item{Income_rate}{description} +#' \item{Income_count}{description} +#' \item{Employment_rate}{description} +#' \item{Employment_count}{description} +#' \item{CIF}{description} +#' \item{ALCOHOL}{description} +#' \item{DRUG}{description} +#' \item{SMR}{description} +#' \item{DEPRESS}{description} +#' \item{LBWT}{description} +#' \item{EMERG}{description} +#' \item{Attendance}{description} +#' \item{Attainment}{description} +#' \item{Noquals}{description} +#' \item{NEET}{description} +#' \item{HESA}{description} +#' \item{drive_petrol}{description} +#' \item{drive_GP}{description} +#' \item{drive_PO}{description} +#' \item{drive_primary}{description} +#' \item{drive_retail}{description} +#' \item{drive_secondary}{description} +#' \item{PT_GP}{description} +#' \item{PT_Post}{description} +#' \item{PT_retail}{description} +#' \item{crime_count}{description} +#' \item{crime_rate}{description} +#' \item{overcrowded_count}{description} +#' \item{nocentralheat_count}{description} +#' \item{overcrowded_rate}{description} +#' \item{nocentralheat_rate}{description} #' ... #' } #' @source \url{http://www.gov.scot/Topics/Statistics/SIMD} diff --git a/README.md b/README.md index d6226b0..9a16986 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,73 @@ -[![Build Status](https://travis-ci.org/TheDataLabScotland/simdr.svg?branch=master)](https://travis-ci.org/TheDataLabScotland/simdr) +[![Build Status](https://travis-ci.org/rmnppt/simdr.svg?branch=master)](https://travis-ci.org/rmnppt/simdr) -An R package to perform the calculation of the Scottish Index of Multiple Deprivation +# The Scottish Index of Multiple Deprivation in R + +## Installation You can install this package with - devtools::install_github("TheDataLabScotland/simdr") +```R +devtools::install_github("rmnppt/simdr") +``` + +## Usage + +You can load in the 2016 simd domain data as follows: + +```R +data("simd16_domains") +``` + +Or you might want to view the more granular indicator data: + +```R +data("simd16_indicators") +``` + +If you want to analyse the data in the way that the SIMD team does you can start by: + + 1. Selecting the indicator variables belonging to a domain + 2. Transform them to be normally distributed + 3. Replace any missing values + +Here is an example using education: + +```R +library(dplyr) + +normalised_education <- simd16_indicators %>% # start with the raw data + select(Attendance, Attainment, Noquals, NEET, HESA) %>% # select relevant columns + mutate(Attendance = normalScores(Attendance, forwards = FALSE)) %>% # replace each column + mutate(Attainment = normalScores(Attainment, forwards = FALSE)) %>% + mutate(Noquals = normalScores(Noquals, forwards = TRUE)) %>% + mutate(NEET = normalScores(NEET, forwards = TRUE)) %>% + mutate(HESA = normalScores(HESA, forwards = FALSE)) %>% + mutate_all(funs(replaceMissing)) # replace missing values +``` + +You will notice that the above gives a warning, there is some missing data. You may want to fill in the missing values, so we include a utility (`replaceMissing`) to replace missing and infinite values with 0, the center of the new normal distribution. + +Notice that when we call `normalScores` we can decide whether a high value indicates deprivation or not, see `?normalScores` for more detail. + +When combining the indicators to give a domain score, we need to apply a different weight to each. The weights are derived through factor analysis of the normalised indicator scores, and the proportional loadings on factor 1 serve as the weightings. We extract the loadings using the getFAWeights function as follows: + +```R +education_weights <- getFAWeights(normalised_education) +``` + +Now that we have the normalised indicator scores and weights, we can combine them with the utility function `combineWeightsAndNorms`. Each normalised indicator variable is multiplied by its weight derived from factor analysis, as follows: + +```R +education_score <- combineWeightsAndNorms(education_weights, normalised_education) +``` + +Finally we rank these weighted scores to generate the domain rank (1 = most deprived). + +```R +education_rank <- rank(-education_score) +``` + +## Further Reading Find more information about the openSIMD project here: diff --git a/data/no_qualifications.RData b/data/no_qualifications.RData index 6e8e96b..c677896 100644 Binary files a/data/no_qualifications.RData and b/data/no_qualifications.RData differ diff --git a/data/sas_simd_domains.RData b/data/sas_simd_domains.RData index 27a04a5..26ea418 100644 Binary files a/data/sas_simd_domains.RData and b/data/sas_simd_domains.RData differ diff --git a/data/sas_weights.RData b/data/sas_weights.RData index 5eeca7e..0331136 100644 Binary files a/data/sas_weights.RData and b/data/sas_weights.RData differ diff --git a/data/simd16_domains.RData b/data/simd16_domains.RData index a306732..8df1cdd 100644 Binary files a/data/simd16_domains.RData and b/data/simd16_domains.RData differ diff --git a/data/simd16_indicators.RData b/data/simd16_indicators.RData index ddb6bbf..f238978 100644 Binary files a/data/simd16_indicators.RData and b/data/simd16_indicators.RData differ diff --git a/man/sas_weights.Rd b/man/sas_weights.Rd index 161f5dd..825341a 100644 --- a/man/sas_weights.Rd +++ b/man/sas_weights.Rd @@ -4,11 +4,54 @@ \name{sas_weights} \alias{sas_weights} \title{Factor analysis weights derived from SAS} -\format{A data frame with ___ rows and ___ variables: +\format{A data frame with 1 rows and 43 variables: \describe{ - \item{variable}{description} - \item{}{Count of individuals with no qualifications} - \item{}{Normalised count, derived from SIMD proceedure in SAS} + + \item{n_neet}{} + \item{n_noquals}{} + \item{n_attain}{} + \item{n_attend}{} + \item{n_hesa}{} + \item{n_cif}{} + \item{n_smr}{} + \item{n_lbwt}{} + \item{n_drug}{} + \item{n_alc}{} + \item{n_depress}{} + \item{n_emerg}{} + \item{n_dr_gp}{} + \item{n_dr_post}{} + \item{n_dr_prim}{} + \item{n_dr_sec}{} + \item{n_dr_retail}{} + \item{n_dr_petrol}{} + \item{n_pt_gp}{} + \item{n_pt_post}{} + \item{n_pt_retail}{} + + \item{wt_neet}{} + \item{wt_noquals}{} + \item{wt_attain}{} + \item{wt_attend}{} + \item{wt_hesa}{} + \item{wt_cif}{} + \item{wt_smr}{} + \item{wt_lbwt}{} + \item{wt_drug}{} + \item{wt_alc}{} + \item{wt_depress}{} + \item{wt_emerg}{} + \item{wt_dr_gp}{} + \item{wt_dr_post}{} + \item{wt_dr_prim}{} + \item{wt_dr_sec}{} + \item{wt_dr_retail}{} + \item{wt_dr_petrol}{} + \item{wt_pt_gp}{} + \item{wt_pt_post}{} + \item{wt_pt_retail}{} + + \item{n}{} ... }} \source{ @@ -18,7 +61,9 @@ sas_weights } \description{ -[describe it here] +We include the Factor Analysis weights calculated in SAS from the 2016 SIMD calculations. +This is mostly for quality control evaluating the correspondence between the SAS and R methodologies. +To see our quality control analysis see [quality assurance section of the openSIMD documentation](https://thedatalabscotland.github.io/openSIMD_site/QA.html) } \details{ Please see the technical notes \url{http://www.gov.scot/Resource/0050/00504822.pdf} for full information on all of the data in SIMD. diff --git a/man/simd16_domains.Rd b/man/simd16_domains.Rd index e1556ed..0c1f6f0 100644 --- a/man/simd16_domains.Rd +++ b/man/simd16_domains.Rd @@ -4,11 +4,21 @@ \name{simd16_domains} \alias{simd16_domains} \title{Domain ranks from published SIMD 2016} -\format{A data frame with ___ rows and ___ variables: +\format{A data frame with 6976 rows and 13 variables: \describe{ - \item{variable}{description} - \item{}{Count of individuals with no qualifications} - \item{}{Normalised count, derived from SIMD proceedure in SAS} + \item{Data_Zone}{} + \item{Intermediate_Zone}{} + \item{Council_area}{} + \item{Total_population}{} + \item{Working_age_population_revised}{} + \item{Overall_SIMD16_rank}{} + \item{Income_domain_2016_rank}{} + \item{Employment_domain_2016_rank}{} + \item{Health_domain_2016_rank}{} + \item{Education_domain_2016_rank}{} + \item{Housing_domain_2016_rank}{} + \item{Access_domain_2016_rank}{} + \item{Crime_domain_2016_rank}{} ... }} \source{ @@ -18,7 +28,8 @@ simd16_domains } \description{ -[describe it here] +We include the domain ranks from the 2016 SIMD for purposes of evaluating the correspondence between the SAS and R methodologies. +To see our quality control analysis see [quality assurance section of the openSIMD documentation](https://thedatalabscotland.github.io/openSIMD_site/QA.html) } \details{ Please see the technical notes \url{http://www.gov.scot/Resource/0050/00504822.pdf} for full information on all of the data in SIMD. diff --git a/man/simd16_indicators.Rd b/man/simd16_indicators.Rd index 70ab45d..044005a 100644 --- a/man/simd16_indicators.Rd +++ b/man/simd16_indicators.Rd @@ -4,11 +4,44 @@ \name{simd16_indicators} \alias{simd16_indicators} \title{Indicator data from published SIMD 2016} -\format{A data frame with ___ rows and ___ variables: +\format{A data frame with 6976 rows and 36 variables: \describe{ - \item{variable}{description} - \item{}{Count of individuals with no qualifications} - \item{}{Normalised count, derived from SIMD proceedure in SAS} + \item{Data_Zone}{description} + \item{Intermediate_Zone}{description} + \item{Council_area}{description} + \item{Total_population}{description} + \item{Working_age_population_revised}{description} + \item{Income_rate}{description} + \item{Income_count}{description} + \item{Employment_rate}{description} + \item{Employment_count}{description} + \item{CIF}{description} + \item{ALCOHOL}{description} + \item{DRUG}{description} + \item{SMR}{description} + \item{DEPRESS}{description} + \item{LBWT}{description} + \item{EMERG}{description} + \item{Attendance}{description} + \item{Attainment}{description} + \item{Noquals}{description} + \item{NEET}{description} + \item{HESA}{description} + \item{drive_petrol}{description} + \item{drive_GP}{description} + \item{drive_PO}{description} + \item{drive_primary}{description} + \item{drive_retail}{description} + \item{drive_secondary}{description} + \item{PT_GP}{description} + \item{PT_Post}{description} + \item{PT_retail}{description} + \item{crime_count}{description} + \item{crime_rate}{description} + \item{overcrowded_count}{description} + \item{nocentralheat_count}{description} + \item{overcrowded_rate}{description} + \item{nocentralheat_rate}{description} ... }} \source{ @@ -18,7 +51,8 @@ simd16_indicators } \description{ -[describe it here] +We include the indicator data from the 2016 SIMD for purposes of evaluating the correspondence between the SAS and R methodologies. +To see our quality control analysis see [quality assurance section of the openSIMD documentation](https://thedatalabscotland.github.io/openSIMD_site/QA.html) } \details{ Please see the technical notes \url{http://www.gov.scot/Resource/0050/00504822.pdf} for full information on all of the data in SIMD. diff --git a/packrat/init.R b/packrat/init.R deleted file mode 100644 index a768be5..0000000 --- a/packrat/init.R +++ /dev/null @@ -1,217 +0,0 @@ -local({ - - ## Helper function to get the path to the library directory for a - ## given packrat project. - getPackratLibDir <- function(projDir = NULL) { - path <- file.path("packrat", "lib", R.version$platform, getRversion()) - - if (!is.null(projDir)) { - - ## Strip trailing slashes if necessary - projDir <- sub("/+$", "", projDir) - - ## Only prepend path if different from current working dir - if (!identical(normalizePath(projDir), normalizePath(getwd()))) - path <- file.path(projDir, path) - } - - path - } - - ## Ensure that we set the packrat library directory relative to the - ## project directory. Normally, this should be the working directory, - ## but we also use '.rs.getProjectDirectory()' if necessary (e.g. we're - ## rebuilding a project while within a separate directory) - libDir <- if (exists(".rs.getProjectDirectory")) - getPackratLibDir(.rs.getProjectDirectory()) - else - getPackratLibDir() - - ## Unload packrat in case it's loaded -- this ensures packrat _must_ be - ## loaded from the private library. Note that `requireNamespace` will - ## succeed if the package is already loaded, regardless of lib.loc! - if ("packrat" %in% loadedNamespaces()) - try(unloadNamespace("packrat"), silent = TRUE) - - if (suppressWarnings(requireNamespace("packrat", quietly = TRUE, lib.loc = libDir))) { - - # Check 'print.banner.on.startup' -- when NA and RStudio, don't print - print.banner <- packrat::get_opts("print.banner.on.startup") - if (print.banner == "auto" && is.na(Sys.getenv("RSTUDIO", unset = NA))) { - print.banner <- TRUE - } else { - print.banner <- FALSE - } - return(packrat::on(print.banner = print.banner)) - } - - ## Escape hatch to allow RStudio to handle bootstrapping. This - ## enables RStudio to provide print output when automagically - ## restoring a project from a bundle on load. - if (!is.na(Sys.getenv("RSTUDIO", unset = NA)) && - is.na(Sys.getenv("RSTUDIO_PACKRAT_BOOTSTRAP", unset = NA))) { - Sys.setenv("RSTUDIO_PACKRAT_BOOTSTRAP" = "1") - setHook("rstudio.sessionInit", function(...) { - # Ensure that, on sourcing 'packrat/init.R', we are - # within the project root directory - if (exists(".rs.getProjectDirectory")) { - owd <- getwd() - setwd(.rs.getProjectDirectory()) - on.exit(setwd(owd), add = TRUE) - } - source("packrat/init.R") - }) - return(invisible(NULL)) - } - - ## Bootstrapping -- only performed in interactive contexts, - ## or when explicitly asked for on the command line - if (interactive() || "--bootstrap-packrat" %in% commandArgs(TRUE)) { - - message("Packrat is not installed in the local library -- ", - "attempting to bootstrap an installation...") - - ## We need utils for the following to succeed -- there are calls to functions - ## in 'restore' that are contained within utils. utils gets loaded at the - ## end of start-up anyhow, so this should be fine - library("utils", character.only = TRUE) - - ## Install packrat into local project library - packratSrcPath <- list.files(full.names = TRUE, - file.path("packrat", "src", "packrat") - ) - - ## No packrat tarballs available locally -- try some other means of installation - if (!length(packratSrcPath)) { - - message("> No source tarball of packrat available locally") - - ## There are no packrat sources available -- try using a version of - ## packrat installed in the user library to bootstrap - if (requireNamespace("packrat", quietly = TRUE) && packageVersion("packrat") >= "0.2.0.99") { - message("> Using user-library packrat (", - packageVersion("packrat"), - ") to bootstrap this project") - } - - ## Couldn't find a user-local packrat -- try finding and using devtools - ## to install - else if (requireNamespace("devtools", quietly = TRUE)) { - message("> Attempting to use devtools::install_github to install ", - "a temporary version of packrat") - library(stats) ## for setNames - devtools::install_github("rstudio/packrat") - } - - ## Try downloading packrat from CRAN if available - else if ("packrat" %in% rownames(available.packages())) { - message("> Installing packrat from CRAN") - install.packages("packrat") - } - - ## Fail -- couldn't find an appropriate means of installing packrat - else { - stop("Could not automatically bootstrap packrat -- try running ", - "\"'install.packages('devtools'); devtools::install_github('rstudio/packrat')\"", - "and restarting R to bootstrap packrat.") - } - - # Restore the project, unload the temporary packrat, and load the private packrat - packrat::restore(prompt = FALSE, restart = TRUE) - - ## This code path only reached if we didn't restart earlier - unloadNamespace("packrat") - requireNamespace("packrat", lib.loc = libDir, quietly = TRUE) - return(packrat::on()) - - } - - ## Multiple packrat tarballs available locally -- try to choose one - ## TODO: read lock file and infer most appropriate from there; low priority because - ## after bootstrapping packrat a restore should do the right thing - if (length(packratSrcPath) > 1) { - warning("Multiple versions of packrat available in the source directory;", - "using packrat source:\n- ", shQuote(packratSrcPath)) - packratSrcPath <- packratSrcPath[[1]] - } - - - lib <- file.path("packrat", "lib", R.version$platform, getRversion()) - if (!file.exists(lib)) { - dir.create(lib, recursive = TRUE) - } - lib <- normalizePath(lib, winslash = "/") - - message("> Installing packrat into project private library:") - message("- ", shQuote(lib)) - - surround <- function(x, with) { - if (!length(x)) return(character()) - paste0(with, x, with) - } - - ## The following is performed because a regular install.packages call can fail - peq <- function(x, y) paste(x, y, sep = " = ") - installArgs <- c( - peq("pkgs", surround(packratSrcPath, with = "'")), - peq("lib", surround(lib, with = "'")), - peq("repos", "NULL"), - peq("type", surround("source", with = "'")) - ) - installCmd <- paste(sep = "", - "utils::install.packages(", - paste(installArgs, collapse = ", "), - ")") - - fullCmd <- paste( - surround(file.path(R.home("bin"), "R"), with = "\""), - "--vanilla", - "--slave", - "-e", - surround(installCmd, with = "\"") - ) - system(fullCmd) - - ## Tag the installed packrat so we know it's managed by packrat - ## TODO: should this be taking information from the lockfile? this is a bit awkward - ## because we're taking an un-annotated packrat source tarball and simply assuming it's now - ## an 'installed from source' version - - ## -- InstallAgent -- ## - installAgent <- 'InstallAgent: packrat 0.4.8-1' - - ## -- InstallSource -- ## - installSource <- 'InstallSource: source' - - packratDescPath <- file.path(lib, "packrat", "DESCRIPTION") - DESCRIPTION <- readLines(packratDescPath) - DESCRIPTION <- c(DESCRIPTION, installAgent, installSource) - cat(DESCRIPTION, file = packratDescPath, sep = "\n") - - # Otherwise, continue on as normal - message("> Attaching packrat") - library("packrat", character.only = TRUE, lib.loc = lib) - - message("> Restoring library") - restore(restart = FALSE) - - # If the environment allows us to restart, do so with a call to restore - restart <- getOption("restart") - if (!is.null(restart)) { - message("> Packrat bootstrap successfully completed. ", - "Restarting R and entering packrat mode...") - return(restart()) - } - - # Callers (source-erers) can define this hidden variable to make sure we don't enter packrat mode - # Primarily useful for testing - if (!exists(".__DONT_ENTER_PACKRAT_MODE__.") && interactive()) { - message("> Packrat bootstrap successfully completed. Entering packrat mode...") - packrat::on() - } - - Sys.unsetenv("RSTUDIO_PACKRAT_BOOTSTRAP") - - } - -}) diff --git a/packrat/packrat.lock b/packrat/packrat.lock deleted file mode 100644 index decee2c..0000000 --- a/packrat/packrat.lock +++ /dev/null @@ -1,193 +0,0 @@ -PackratFormat: 1.4 -PackratVersion: 0.4.8.1 -RVersion: 3.4.0 -Repos: CRAN=https://cran.rstudio.com/ - -Package: BH -Source: CRAN -Version: 1.62.0-1 -Hash: 14dfb3e8ffe20996118306ff4de1fab2 - -Package: DBI -Source: CRAN -Version: 0.6-1 -Hash: 4aef5bda70897c1663d5b8bae2f4419a - -Package: R6 -Source: CRAN -Version: 2.2.1 -Hash: 530f0b839551f96ec991ce4f93156ee1 - -Package: Rcpp -Source: CRAN -Version: 0.12.10 -Hash: 6cf65d0dd6a92f2d43c8d4805d33efe9 - -Package: assertthat -Source: CRAN -Version: 0.2.0 -Hash: e8805df54c65ac96d50235c44a82615c - -Package: backports -Source: CRAN -Version: 1.0.5 -Hash: 8b835bdc5447f2c76fda198e17d6bda4 - -Package: brew -Source: CRAN -Version: 1.0-6 -Hash: 931f9972deae0f205e1c78a51f33149b - -Package: commonmark -Source: CRAN -Version: 1.2 -Hash: 1290583b9d16fb60322126a8698fb729 - -Package: crayon -Source: CRAN -Version: 1.3.2 -Hash: 576a9d297a567d6a5ebd164ca5221590 - -Package: curl -Source: CRAN -Version: 2.6 -Hash: 8162b82ca4809c0d63c30aedbd7348e0 - -Package: desc -Source: CRAN -Version: 1.1.0 -Hash: 346d3477f87b89692dd1379eaed1a1be -Requires: R6, assertthat, crayon, rprojroot - -Package: devtools -Source: CRAN -Version: 1.13.1 -Hash: 8dadb6c6a916c8312dddc7b4d394c9f3 -Requires: digest, git2r, httr, jsonlite, memoise, rstudioapi, whisker, - withr - -Package: digest -Source: CRAN -Version: 0.6.12 -Hash: e53fb8c58673df868183697e39a6a4d6 - -Package: dplyr -Source: CRAN -Version: 0.5.0 -Hash: 673660fd0b947477dab1044abc8b2c95 -Requires: BH, R6, Rcpp, assertthat, magrittr, DBI, lazyeval, tibble - -Package: git2r -Source: CRAN -Version: 0.18.0 -Hash: 9dfaafbcca68be29b89ef7783dc1dac0 - -Package: httr -Source: CRAN -Version: 1.2.1 -Hash: 7de1f8f760441881804af7c1ff324340 -Requires: R6, curl, jsonlite, mime, openssl - -Package: jsonlite -Source: CRAN -Version: 1.4 -Hash: 24cc0ffeb1771d710173d9803a131870 - -Package: lazyeval -Source: CRAN -Version: 0.2.0 -Hash: 3d6e7608e65bbf5cb170dab1e3c9ed8b - -Package: magrittr -Source: CRAN -Version: 1.5 -Hash: bdc4d48c3135e8f3b399536ddf160df4 - -Package: memoise -Source: CRAN -Version: 1.1.0 -Hash: 410fcd334bc626db100237cc1370f2e9 -Requires: digest - -Package: mime -Source: CRAN -Version: 0.5 -Hash: 463550cf44fb6f0a2359368f42eebe62 - -Package: mnormt -Source: CRAN -Version: 1.5-5 -Hash: d0d5efbb1fb26d2dc5f9394c223084b5 - -Package: openssl -Source: CRAN -Version: 0.9.6 -Hash: 5f4711e142a44655dfea4d64fcf2f641 - -Package: packrat -Source: CRAN -Version: 0.4.8-1 -Hash: 6ad605ba7b4b476d84be6632393f5765 - -Package: psych -Source: CRAN -Version: 1.7.3.21 -Hash: 8111794761e5c334c250e868a9252ff9 -Requires: mnormt - -Package: purrr -Source: CRAN -Version: 0.2.2 -Hash: 9f218b40dee7fe7f942039f974bd98b8 -Requires: BH, Rcpp, magrittr, dplyr, lazyeval - -Package: roxygen2 -Source: CRAN -Version: 6.0.1 -Hash: 7a75b821e00443c60a239fa4070b4117 -Requires: R6, Rcpp, brew, commonmark, desc, digest, stringi, stringr, - xml2 - -Package: rprojroot -Source: CRAN -Version: 1.2 -Hash: fdcac51a7f47decd60556ceefc3c26b1 -Requires: backports - -Package: rstudioapi -Source: CRAN -Version: 0.6 -Hash: fd256f8bfb9a64cc35f98b0decb1a79f - -Package: stringi -Source: CRAN -Version: 1.1.5 -Hash: b6308e49357a0b475f433599e0d8b5eb - -Package: stringr -Source: CRAN -Version: 1.2.0 -Hash: 25a86d7f410513ebb7c0bc6a5e16bdc3 -Requires: magrittr, stringi - -Package: tibble -Source: CRAN -Version: 1.3.0 -Hash: 8de64ed3345488e66b676875ed1ebdce -Requires: Rcpp, lazyeval - -Package: whisker -Source: CRAN -Version: 0.3-2 -Hash: 803d662762e532705c2c066a82d066e7 - -Package: withr -Source: CRAN -Version: 1.0.2 -Hash: 774eb7be9087cdc24b53b74e5359cfac - -Package: xml2 -Source: CRAN -Version: 1.1.1 -Hash: 19ad10ef8e73cb435eb49f9d5d259980 -Requires: BH, Rcpp diff --git a/packrat/packrat.opts b/packrat/packrat.opts deleted file mode 100644 index 7f6839c..0000000 --- a/packrat/packrat.opts +++ /dev/null @@ -1,15 +0,0 @@ -auto.snapshot: TRUE -use.cache: FALSE -print.banner.on.startup: auto -vcs.ignore.lib: TRUE -vcs.ignore.src: FALSE -external.packages: -local.repos: -load.external.packages.on.startup: TRUE -ignored.packages: -quiet.package.installation: TRUE -snapshot.recommended.packages: FALSE -snapshot.fields: - Imports - Depends - LinkingTo diff --git a/packrat/src/BH/BH_1.62.0-1.tar.gz b/packrat/src/BH/BH_1.62.0-1.tar.gz deleted file mode 100644 index 0d8a6ff..0000000 Binary files a/packrat/src/BH/BH_1.62.0-1.tar.gz and /dev/null differ diff --git a/packrat/src/DBI/DBI_0.6-1.tar.gz b/packrat/src/DBI/DBI_0.6-1.tar.gz deleted file mode 100644 index f290029..0000000 Binary files a/packrat/src/DBI/DBI_0.6-1.tar.gz and /dev/null differ diff --git a/packrat/src/R6/R6_2.2.1.tar.gz b/packrat/src/R6/R6_2.2.1.tar.gz deleted file mode 100644 index 1778c99..0000000 Binary files a/packrat/src/R6/R6_2.2.1.tar.gz and /dev/null differ diff --git a/packrat/src/Rcpp/Rcpp_0.12.10.tar.gz b/packrat/src/Rcpp/Rcpp_0.12.10.tar.gz deleted file mode 100644 index 6c5c192..0000000 Binary files a/packrat/src/Rcpp/Rcpp_0.12.10.tar.gz and /dev/null differ diff --git a/packrat/src/assertthat/assertthat_0.2.0.tar.gz b/packrat/src/assertthat/assertthat_0.2.0.tar.gz deleted file mode 100644 index a48c9aa..0000000 Binary files a/packrat/src/assertthat/assertthat_0.2.0.tar.gz and /dev/null differ diff --git a/packrat/src/backports/backports_1.0.5.tar.gz b/packrat/src/backports/backports_1.0.5.tar.gz deleted file mode 100644 index 9d79397..0000000 Binary files a/packrat/src/backports/backports_1.0.5.tar.gz and /dev/null differ diff --git a/packrat/src/brew/brew_1.0-6.tar.gz b/packrat/src/brew/brew_1.0-6.tar.gz deleted file mode 100644 index e3c9598..0000000 Binary files a/packrat/src/brew/brew_1.0-6.tar.gz and /dev/null differ diff --git a/packrat/src/commonmark/commonmark_1.2.tar.gz b/packrat/src/commonmark/commonmark_1.2.tar.gz deleted file mode 100644 index e295f52..0000000 Binary files a/packrat/src/commonmark/commonmark_1.2.tar.gz and /dev/null differ diff --git a/packrat/src/crayon/crayon_1.3.2.tar.gz b/packrat/src/crayon/crayon_1.3.2.tar.gz deleted file mode 100644 index 8943f42..0000000 Binary files a/packrat/src/crayon/crayon_1.3.2.tar.gz and /dev/null differ diff --git a/packrat/src/curl/curl_2.6.tar.gz b/packrat/src/curl/curl_2.6.tar.gz deleted file mode 100644 index 1e3a247..0000000 Binary files a/packrat/src/curl/curl_2.6.tar.gz and /dev/null differ diff --git a/packrat/src/desc/desc_1.1.0.tar.gz b/packrat/src/desc/desc_1.1.0.tar.gz deleted file mode 100644 index ff73d43..0000000 Binary files a/packrat/src/desc/desc_1.1.0.tar.gz and /dev/null differ diff --git a/packrat/src/devtools/devtools_1.13.1.tar.gz b/packrat/src/devtools/devtools_1.13.1.tar.gz deleted file mode 100644 index ca0e5b6..0000000 Binary files a/packrat/src/devtools/devtools_1.13.1.tar.gz and /dev/null differ diff --git a/packrat/src/digest/digest_0.6.12.tar.gz b/packrat/src/digest/digest_0.6.12.tar.gz deleted file mode 100644 index 376f954..0000000 Binary files a/packrat/src/digest/digest_0.6.12.tar.gz and /dev/null differ diff --git a/packrat/src/dplyr/dplyr_0.5.0.tar.gz b/packrat/src/dplyr/dplyr_0.5.0.tar.gz deleted file mode 100644 index ac12287..0000000 Binary files a/packrat/src/dplyr/dplyr_0.5.0.tar.gz and /dev/null differ diff --git a/packrat/src/git2r/git2r_0.18.0.tar.gz b/packrat/src/git2r/git2r_0.18.0.tar.gz deleted file mode 100644 index f52c114..0000000 Binary files a/packrat/src/git2r/git2r_0.18.0.tar.gz and /dev/null differ diff --git a/packrat/src/httr/httr_1.2.1.tar.gz b/packrat/src/httr/httr_1.2.1.tar.gz deleted file mode 100644 index c02f0d5..0000000 Binary files a/packrat/src/httr/httr_1.2.1.tar.gz and /dev/null differ diff --git a/packrat/src/jsonlite/jsonlite_1.4.tar.gz b/packrat/src/jsonlite/jsonlite_1.4.tar.gz deleted file mode 100644 index 5ae01a9..0000000 Binary files a/packrat/src/jsonlite/jsonlite_1.4.tar.gz and /dev/null differ diff --git a/packrat/src/lazyeval/lazyeval_0.2.0.tar.gz b/packrat/src/lazyeval/lazyeval_0.2.0.tar.gz deleted file mode 100644 index 1a7507c..0000000 Binary files a/packrat/src/lazyeval/lazyeval_0.2.0.tar.gz and /dev/null differ diff --git a/packrat/src/magrittr/magrittr_1.5.tar.gz b/packrat/src/magrittr/magrittr_1.5.tar.gz deleted file mode 100644 index e2f9860..0000000 Binary files a/packrat/src/magrittr/magrittr_1.5.tar.gz and /dev/null differ diff --git a/packrat/src/memoise/memoise_1.1.0.tar.gz b/packrat/src/memoise/memoise_1.1.0.tar.gz deleted file mode 100644 index b150108..0000000 Binary files a/packrat/src/memoise/memoise_1.1.0.tar.gz and /dev/null differ diff --git a/packrat/src/mime/mime_0.5.tar.gz b/packrat/src/mime/mime_0.5.tar.gz deleted file mode 100644 index 221519b..0000000 Binary files a/packrat/src/mime/mime_0.5.tar.gz and /dev/null differ diff --git a/packrat/src/mnormt/mnormt_1.5-5.tar.gz b/packrat/src/mnormt/mnormt_1.5-5.tar.gz deleted file mode 100644 index eb5249c..0000000 Binary files a/packrat/src/mnormt/mnormt_1.5-5.tar.gz and /dev/null differ diff --git a/packrat/src/openssl/openssl_0.9.6.tar.gz b/packrat/src/openssl/openssl_0.9.6.tar.gz deleted file mode 100644 index ab07e28..0000000 Binary files a/packrat/src/openssl/openssl_0.9.6.tar.gz and /dev/null differ diff --git a/packrat/src/packrat/packrat_0.4.8-1.tar.gz b/packrat/src/packrat/packrat_0.4.8-1.tar.gz deleted file mode 100644 index f16e936..0000000 Binary files a/packrat/src/packrat/packrat_0.4.8-1.tar.gz and /dev/null differ diff --git a/packrat/src/psych/psych_1.7.3.21.tar.gz b/packrat/src/psych/psych_1.7.3.21.tar.gz deleted file mode 100644 index adf9066..0000000 Binary files a/packrat/src/psych/psych_1.7.3.21.tar.gz and /dev/null differ diff --git a/packrat/src/purrr/purrr_0.2.2.tar.gz b/packrat/src/purrr/purrr_0.2.2.tar.gz deleted file mode 100644 index 58ec669..0000000 Binary files a/packrat/src/purrr/purrr_0.2.2.tar.gz and /dev/null differ diff --git a/packrat/src/roxygen2/roxygen2_6.0.1.tar.gz b/packrat/src/roxygen2/roxygen2_6.0.1.tar.gz deleted file mode 100644 index 56dca93..0000000 Binary files a/packrat/src/roxygen2/roxygen2_6.0.1.tar.gz and /dev/null differ diff --git a/packrat/src/rprojroot/rprojroot_1.2.tar.gz b/packrat/src/rprojroot/rprojroot_1.2.tar.gz deleted file mode 100644 index 6ffb493..0000000 Binary files a/packrat/src/rprojroot/rprojroot_1.2.tar.gz and /dev/null differ diff --git a/packrat/src/rstudioapi/rstudioapi_0.6.tar.gz b/packrat/src/rstudioapi/rstudioapi_0.6.tar.gz deleted file mode 100644 index 2ba9ed2..0000000 Binary files a/packrat/src/rstudioapi/rstudioapi_0.6.tar.gz and /dev/null differ diff --git a/packrat/src/stringi/stringi_1.1.5.tar.gz b/packrat/src/stringi/stringi_1.1.5.tar.gz deleted file mode 100644 index 0f62be6..0000000 Binary files a/packrat/src/stringi/stringi_1.1.5.tar.gz and /dev/null differ diff --git a/packrat/src/stringr/stringr_1.2.0.tar.gz b/packrat/src/stringr/stringr_1.2.0.tar.gz deleted file mode 100644 index 7778909..0000000 Binary files a/packrat/src/stringr/stringr_1.2.0.tar.gz and /dev/null differ diff --git a/packrat/src/tibble/tibble_1.3.0.tar.gz b/packrat/src/tibble/tibble_1.3.0.tar.gz deleted file mode 100644 index 6404724..0000000 Binary files a/packrat/src/tibble/tibble_1.3.0.tar.gz and /dev/null differ diff --git a/packrat/src/whisker/whisker_0.3-2.tar.gz b/packrat/src/whisker/whisker_0.3-2.tar.gz deleted file mode 100644 index 7e6576e..0000000 Binary files a/packrat/src/whisker/whisker_0.3-2.tar.gz and /dev/null differ diff --git a/packrat/src/withr/withr_1.0.2.tar.gz b/packrat/src/withr/withr_1.0.2.tar.gz deleted file mode 100644 index 5b531fa..0000000 Binary files a/packrat/src/withr/withr_1.0.2.tar.gz and /dev/null differ diff --git a/packrat/src/xml2/xml2_1.1.1.tar.gz b/packrat/src/xml2/xml2_1.1.1.tar.gz deleted file mode 100644 index f3b209f..0000000 Binary files a/packrat/src/xml2/xml2_1.1.1.tar.gz and /dev/null differ diff --git a/simdr.Rproj b/simdr.Rproj index f0d6187..04f5ba3 100644 --- a/simdr.Rproj +++ b/simdr.Rproj @@ -18,4 +18,5 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageBuildArgs: --resave-data PackageRoxygenize: rd,collate,namespace,vignette