Skip to content

Commit

Permalink
Add VALID_CASE check and improve multiple shift variable and amount f…
Browse files Browse the repository at this point in the history
…unctionality
  • Loading branch information
adamvi committed Nov 21, 2021
1 parent 875aa3e commit 2087a0b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cfaTools
Version: 0.0-1.993
Date: 2021-11-2
Version: 0.0-1.994
Date: 2021-11-21
Title: Center for Assessment Tools for Large Scale Educational Assessment Analysis
Description: Center for Assessment developed Tools for Large Scale Educational Assessment.
Authors@R: c(person(given=c("Damian", "W."), family="Betebenner", email="[email protected]", role=c("aut", "cre")),
Expand Down
13 changes: 9 additions & 4 deletions R/getShiftedValues.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ function(
res[]
}

if ("VALID_CASE" %in% names(data_table)) valid_case <- "VALID_CASE" else valid_case <- NULL
data_table[,FILTER_VARIABLE:=seq.int(dim(data_table)[1])]
data_table_complete <- completeDT(data_table[,c("FILTER_VARIABLE", shift_period, shift_group, shift_variable), with=FALSE], cols=c(shift_period, shift_group))
setkeyv(data_table_complete, c(shift_group, shift_period))
data_table_complete[, paste(shift_variable, toupper(shift_type), shift_amount, sep="_") := shift(get(shift_variable), n=shift_amount, type=shift_type), by=shift_group]
data_table_complete <- completeDT(data_table[,c("FILTER_VARIABLE", shift_group, shift_period, valid_case, shift_variable), with=FALSE], cols=c(shift_period, shift_group))
if (!is.null(valid_case)) data_table_complete[is.na(VALID_CASE), VALID_CASE := "VALID_CASE"]
setkeyv(data_table_complete, c(shift_group, shift_period, valid_case))
shift_var_names <- paste(rep(shift_variable, each=length(shift_amount)), toupper(shift_type), shift_amount, sep="_")
data_table_complete[, (shift_var_names) := shift(.SD, n=shift_amount, type=shift_type), .SDcols=shift_variable, by=shift_group]
# data_table_complete[, paste(shift_variable, toupper(shift_type), shift_amount, sep="_") := shift(get(shift_variable), n=shift_amount, type=shift_type), by=shift_group]
data_table_complete <- data_table_complete[!is.na(FILTER_VARIABLE)]
setkeyv(data_table_complete, "FILTER_VARIABLE")
data_table[,paste(shift_variable, toupper(shift_type), shift_amount, sep="_") := data_table_complete[, paste(shift_variable, toupper(shift_type), shift_amount, sep="_"), with=FALSE]]
data_table[, (shift_var_names) := data_table_complete[, (shift_var_names), with=FALSE]]
# data_table[,paste(shift_variable, toupper(shift_type), shift_amount, sep="_") := data_table_complete[, paste(shift_variable, toupper(shift_type), shift_amount, sep="_"), with=FALSE]]
return(data_table[,FILTER_VARIABLE:=NULL])
} ### END getShiftedValues function
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ function(libname, pkgname) {
`.onAttach` <-
function(libname, pkgname) {
if (interactive()) {
packageStartupMessage(magenta$bold('cfaTools',paste(paste0(unlist(strsplit(as.character(packageVersion("cfaTools")), "[.]")), c(".", "-", ".", "")), collapse=""),' (11-2-2021). For help: >help("cfaTools") or visit https://centerforassessment.github.io/cfaTools'))
packageStartupMessage(magenta$bold('cfaTools',paste(paste0(unlist(strsplit(as.character(packageVersion("cfaTools")), "[.]")), c(".", "-", ".", "")), collapse=""),' (11-21-2021). For help: >help("cfaTools") or visit https://centerforassessment.github.io/cfaTools'))
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cfaTools
[![R-CMD-check](https://github.com/CenterForAssessment/cfaTools/workflows/R-CMD-check/badge.svg)](https://github.com/CenterForAssessment/cfaTools/actions)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/centerforassessment/cfaTools?branch=master&svg=true)](https://ci.appveyor.com/project/centerforassessment/cfaTools)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/cfaTools)](https://cran.r-project.org/package=cfaTools)
[![Development Version](https://img.shields.io/badge/devel-0.0--1.992-brightgreen.svg)](https://github.com/CenterForAssessment/cfaTools)
[![Development Version](https://img.shields.io/badge/devel-0.0--1.994-brightgreen.svg)](https://github.com/CenterForAssessment/cfaTools)
[![License](https://img.shields.io/badge/license-GPL%203-brightgreen.svg?style=flat)](https://github.com/CenterForAssessment/cfaTools/blob/master/LICENSE.md)


Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ citEntry(entry = "Manual",
title = "{cfaTools}: Center for Assessment Tools for Large Scale Educational Assessment Analysis",
author = personList(as.person("Damian W. Betebenner"), as.person("Adam R. Van Iwaarden"), as.person("Nathan Dadey"), as.person("Joseph Martineau")),
year = "2021",
note = "R package version 0.0-1.993",
note = "R package version 0.0-1.994",
url = "https://centerforassessment.github.io/cfaTools/",

textVersion = paste("Damian W. Betebenner, Adam R. Van Iwaarden, Nathan Dadey and Joseph Martineau (2021).",
"cfaTools: Center for Assessment Tools for Large Scale Educational Assessment Analysis",
"(R package version 0.0-1.993",
"(R package version 0.0-1.994",
"URL https://centerforassessment.github.io/cfaTools/")
)
4 changes: 2 additions & 2 deletions man/cfaTools-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Center for Assessment developed Tools for Large Scale Educational Assessment.
\tabular{ll}{
Package: \tab cfaTools\cr
Type: \tab Package\cr
Version: \tab 0.0-1.993\cr
Date: \tab 2021-11-2\cr
Version: \tab 0.0-1.994\cr
Date: \tab 2021-11-21\cr
License: \tab GPL-3\cr
LazyLoad: \tab yes\cr
}
Expand Down

0 comments on commit 2087a0b

Please sign in to comment.