R/old_sat_writingreading_to_new_ebrw.R

#' Recode old SAT writing plus critical reading sections to new SAT EBRW section
#'
#' Function to recode old SAT writing plus critical reading sections
#' to new SAT Evidence-Based Reading and Writing Section test.
#' Missing and unmatched values are coded as missing.
#'
#' @param x numeric vector of old SAT writing plus critical reading section values
#' @return integer vector of new SAT EBRW section values
#' @examples
#' require(dplyr)
#'
#' old_sat_vals <- round(sample(400:1600, 10), -1)
#' new_sat_vals <- old_sat_writingreading_to_new_ebrw(old_sat_vals)
#' old_new_vals <- data.frame(old_sat_vals, new_sat_vals)
#' print(old_new_vals)
#'
#' old_new_vals %>%
#'     mutate(new_sat_vals_piped = old_sat_writingreading_to_new_ebrw(old_sat_vals))
#' @export
old_sat_writingreading_to_new_ebrw <- function(x){
  dplyr::recode(x,
                `400`= 200L,
                `410`= 210L,
                `420`= 220L,
                `430`= 230L,
                `440`= 240L,
                `450`= 260L,
                `460`= 270L,
                `470`= 280L,
                `480`= 290L,
                `490`= 300L,
                `500`= 310L,
                `510`= 310L,
                `520`= 320L,
                `530`= 320L,
                `540`= 330L,
                `550`= 330L,
                `560`= 330L,
                `570`= 340L,
                `580`= 340L,
                `590`= 350L,
                `600`= 350L,
                `610`= 360L,
                `620`= 360L,
                `630`= 360L,
                `640`= 370L,
                `650`= 370L,
                `660`= 380L,
                `670`= 380L,
                `680`= 390L,
                `690`= 390L,
                `700`= 400L,
                `710`= 400L,
                `720`= 410L,
                `730`= 410L,
                `740`= 420L,
                `750`= 420L,
                `760`= 430L,
                `770`= 430L,
                `780`= 440L,
                `790`= 440L,
                `800`= 450L,
                `810`= 450L,
                `820`= 460L,
                `830`= 460L,
                `840`= 470L,
                `850`= 480L,
                `860`= 480L,
                `870`= 490L,
                `880`= 490L,
                `890`= 500L,
                `900`= 500L,
                `910`= 510L,
                `920`= 510L,
                `930`= 520L,
                `940`= 530L,
                `950`= 530L,
                `960`= 540L,
                `970`= 540L,
                `980`= 550L,
                `990`= 550L,
                `1000` = 560L,
                `1010` = 560L,
                `1020` = 570L,
                `1030` = 570L,
                `1040` = 580L,
                `1050` = 580L,
                `1060` = 590L,
                `1070` = 590L,
                `1080` = 600L,
                `1090` = 600L,
                `1100` = 610L,
                `1110` = 610L,
                `1120` = 620L,
                `1130` = 620L,
                `1140` = 630L,
                `1150` = 630L,
                `1160` = 640L,
                `1170` = 640L,
                `1180` = 650L,
                `1190` = 650L,
                `1200` = 650L,
                `1210` = 660L,
                `1220` = 660L,
                `1230` = 670L,
                `1240` = 670L,
                `1250` = 680L,
                `1260` = 680L,
                `1270` = 680L,
                `1280` = 690L,
                `1290` = 690L,
                `1300` = 700L,
                `1310` = 700L,
                `1320` = 700L,
                `1330` = 710L,
                `1340` = 710L,
                `1350` = 710L,
                `1360` = 720L,
                `1370` = 720L,
                `1380` = 730L,
                `1390` = 730L,
                `1400` = 730L,
                `1410` = 740L,
                `1420` = 740L,
                `1430` = 740L,
                `1440` = 750L,
                `1450` = 750L,
                `1460` = 750L,
                `1470` = 760L,
                `1480` = 760L,
                `1490` = 760L,
                `1500` = 770L,
                `1510` = 770L,
                `1520` = 770L,
                `1530` = 780L,
                `1540` = 780L,
                `1550` = 780L,
                `1560` = 790L,
                `1570` = 790L,
                `1580` = 800L,
                `1590` = 800L,
                `1600` = 800L,
                .default = NA_integer_)
}
capturelabs/satconcordance documentation built on May 28, 2019, 7:11 a.m.