diff --git a/R/studentGrowthPercentiles.R b/R/studentGrowthPercentiles.R index 7b62c073..b073d6a3 100644 --- a/R/studentGrowthPercentiles.R +++ b/R/studentGrowthPercentiles.R @@ -152,7 +152,7 @@ function(panel.data, ## REQUIRED tmp.res <- rq(method="br", ...)[['coefficients']] } else { tmp.res <- try(rq(method=rq.method, ...)[['coefficients']], silent=TRUE) - if ("try-error" %in% class(tmp.res)) { + if (inherits(tmp.res, "try-error")) { tmp.res <- rq(method="br", ...)[['coefficients']] } } @@ -200,14 +200,14 @@ function(panel.data, ## REQUIRED if (par.start$par.type == 'MULTICORE') { tmp.mtx <- mclapply(par.start$TAUS.LIST, function(x) eval(parse(text=paste0("rq.sgp(tmp.data[[", tmp.num.variables, "]] ~ ", substring(mod,4), ", tau=x, data=tmp.data, my.taus=x)"))), mc.cores=par.start$workers, mc.preschedule = FALSE) - if (any(tmp.tf <- sapply(tmp.mtx, function(x) identical(class(x), "try-error")))) return(list(RQ_ERROR=sapply(which(tmp.tf), function(f) tmp.mtx[[f]][1L]))) + if (any(tmp.tf <- sapply(tmp.mtx, function(x) inherits(x, "try-error")))) return(list(RQ_ERROR=sapply(which(tmp.tf), function(f) tmp.mtx[[f]][1L]))) tmp.mtx <- do.call(cbind, tmp.mtx) } if (par.start$par.type == 'SNOW') { tmp.mtx <- parLapplyLB(par.start$internal.cl, par.start$TAUS.LIST, function(x) eval(parse(text=paste0("rq.sgp(tmp.data[[", tmp.num.variables, "]] ~ ", substring(mod,4), ", tau=x, data=tmp.data, my.taus=x)")))) - if (any(tmp.tf <- sapply(tmp.mtx, function(x) identical(class(x), "try-error")))) return(list(RQ_ERROR=sapply(which(tmp.tf), function(f) tmp.mtx[[f]][1L]))) + if (any(tmp.tf <- sapply(tmp.mtx, function(x) inherits(x, "try-error")))) return(list(RQ_ERROR=sapply(which(tmp.tf), function(f) tmp.mtx[[f]][1L]))) tmp.mtx <- do.call(cbind, tmp.mtx) } } @@ -767,13 +767,13 @@ function(panel.data, ## REQUIRED if (!(is.matrix(panel.data) || is.list(panel.data))) { stop("Supplied panel.data not of a supported class. See help for details of supported classes") } - if (identical(class(panel.data), "list") && !"Panel_Data" %in% names(panel.data)) { + if (inherits(panel.data, "list") && !"Panel_Data" %in% names(panel.data)) { stop("Supplied panel.data missing Panel_Data") } - if (identical(class(panel.data), "list") && !is.data.frame(panel.data[["Panel_Data"]])) { + if (inherits(panel.data, "list") && !is.data.frame(panel.data[["Panel_Data"]])) { stop("Supplied panel.data$Panel_Data is not a data.frame or a data.table") } - if (identical(class(panel.data), "list") && !is.null(panel.data[['Coefficient_Matrices']])) { + if (inherits(panel.data, "list") && !is.null(panel.data[['Coefficient_Matrices']])) { panel.data[['Coefficient_Matrices']] <- checksplineMatrix(panel.data[['Coefficient_Matrices']]) } @@ -821,7 +821,7 @@ function(panel.data, ## REQUIRED stop("use.my.knots.boundaries must be supplied as a list or character abbreviation. See help page for details.") } if (is.list(use.my.knots.boundaries)) { - if (!identical(class(panel.data), "list")) { + if (!inherits(panel.data, "list")) { stop("use.my.knots.boundaries is only appropriate when panel data is of class list. See help page for details.") } if (!identical(names(use.my.knots.boundaries), c("my.year", "my.subject")) & @@ -846,7 +846,7 @@ function(panel.data, ## REQUIRED } if (!is.null(use.my.coefficient.matrices) && !identical(use.my.coefficient.matrices, TRUE)) { - if (!identical(class(panel.data), "list")) { + if (!inherits(panel.data, "list")) { stop("use.my.coefficient.matrices is only appropriate when panel data is of class list. See help page for details.") } if (!is.list(use.my.coefficient.matrices)) { @@ -1092,7 +1092,7 @@ function(panel.data, ## REQUIRED Coefficient_Matrices <- Cutscores <- Goodness_of_Fit <- Knots_Boundaries <- Panel_Data <- SGPercentiles <- SGProjections <- Simulated_SGPs <- SGP_STANDARD_ERROR <- Verbose_Messages <- NULL SGP_SIMEX <- SGP_SIMEX_RANKED <- SGP_NORM_GROUP_SCALE_SCORES <- SGP_NORM_GROUP_DATES <- SGP_NORM_GROUP <- NULL - if (identical(class(panel.data), "list")) { + if (inherits(panel.data, "list")) { for (i in tmp.objects) { if (!is.null(panel.data[[i]])) { assign(i, panel.data[[i]]) @@ -1130,7 +1130,7 @@ function(panel.data, ## REQUIRED if (is.data.frame(panel.data)) { Panel_Data <- as.data.table(panel.data) } - if (identical(class(panel.data), "list") && !is.data.table(panel.data[["Panel_Data"]])) { + if (inherits(panel.data, "list") && !is.data.table(panel.data[["Panel_Data"]])) { Panel_Data <- as.data.table(panel.data[["Panel_Data"]]) } @@ -1312,7 +1312,7 @@ function(panel.data, ## REQUIRED if (is.null(content_area.progression)) { content_area.progression <- rep(sgp.labels$my.subject, length(tmp.gp)) } else { - if (!identical(class(content_area.progression), "character")) { + if (!inherits(content_area.progression, "character")) { stop("The 'content_area.progression' vector/argument should be a character vector. See help page for details.") } if (!identical(tail(content_area.progression, 1L), sgp.labels[['my.subject']])) { @@ -1341,7 +1341,7 @@ function(panel.data, ## REQUIRED year.progression <- rep("BASELINE", length(tmp.gp)) year.progression.for.norm.group <- tail(rev(yearIncrement(sgp.labels[['my.year']], c(0, -cumsum(rev(year_lags.progression))))), length(tmp.gp)) } - if (!identical(class(year.progression), "character")) { + if (!inherits(year.progression, "character")) { stop("year.area.progression should be a character vector. See help page for details.") } if (!identical(sgp.labels[['my.extra.label']], "BASELINE") && !identical(tail(year.progression, 1L), sgp.labels[['my.year']])) { @@ -1819,6 +1819,10 @@ function(panel.data, ## REQUIRED if (identical(sgp.labels[['my.extra.label']], "BASELINE") && "SGP_ORDER" %in% names(quantile.data)) setnames(quantile.data, gsub("SGP_ORDER", "SGP_BASELINE_ORDER", names(quantile.data))) if (identical(sgp.labels[['my.extra.label']], "BASELINE") && "SGP_NORM_GROUP" %in% names(quantile.data)) setnames(quantile.data, gsub("SGP_NORM_GROUP", "SGP_NORM_GROUP_BASELINE", names(quantile.data))) if (identical(sgp.labels[['my.extra.label']], "BASELINE") && simex.tf) setnames(quantile.data, gsub("_SIMEX", "_SIMEX_BASELINE", names(quantile.data))) # SGP_SIMEX and SGP_SIMEX_RANKED + if (identical(sgp.labels[["my.extra.label"]], "BASELINE") && return.prior.scale.score) setnames(quantile.data, "SCALE_SCORE_PRIOR", "SCALE_SCORE_PRIOR_BASELINE") + if (identical(sgp.labels[["my.extra.label"]], "BASELINE") && return.prior.scale.score.standardized) setnames(quantile.data, "SCALE_SCORE_PRIOR_STANDARDIZED", "SCALE_SCORE_PRIOR_STANDARDIZED_BASELINE") + if (identical(sgp.labels[["my.extra.label"]], "BASELINE") && !is.null(percentile.cuts)) setnames(quantile.data, gsub("PERCENTILE_CUT_", "PERCENTILE_CUT_BASELINE_", names(quantile.data))) + if (identical(sgp.labels[['my.extra.label']], "EQUATED")) setnames(quantile.data, "SGP", "SGP_EQUATED") if (identical(sgp.labels[['my.extra.label']], "EQUATED") && tf.growth.levels) setnames(quantile.data, "SGP_LEVEL", "SGP_LEVEL_EQUATED") if (identical(sgp.labels[['my.extra.label']], "EQUATED") && "SGP_NORM_GROUP" %in% names(quantile.data)) setnames(quantile.data, gsub("SGP_NORM_GROUP", "SGP_NORM_GROUP_EQUATED", names(quantile.data))) diff --git a/R/studentGrowthProjections.R b/R/studentGrowthProjections.R index 4e91e8ad..f9d98e4e 100644 --- a/R/studentGrowthProjections.R +++ b/R/studentGrowthProjections.R @@ -518,7 +518,7 @@ function(panel.data, ## REQUIRED if (!(all(c("Panel_Data", "Coefficient_Matrices", "Knots_Boundaries") %in% names(panel.data)))) { stop("Supplied panel.data missing Panel_Data, Coefficient_Matrices, and/or Knots_Boundaries. See help page for details") } - if (identical(class(panel.data[["Panel_Data"]]), "data.frame")) { + if (inherits(panel.data[["Panel_Data"]], "data.frame")) { panel.data[["Panel_Data"]] <- as.data.table(panel.data[["Panel_Data"]]) }} @@ -821,7 +821,7 @@ function(panel.data, ## REQUIRED if (is.null(content_area.progression)) { content_area.progression <- rep(sgp.labels[['my.subject']], length(grade.progression)) } else { - if (!identical(class(content_area.progression), "character")) { + if (!inherits(content_area.progression, "character")) { stop("content_area.progression should be a character vector. See help page for details.") } if (length(content_area.progression) != length(grade.progression)) { diff --git a/data/SGPstateData.rda b/data/SGPstateData.rda index 6d1dedd8..567ff0b4 100644 Binary files a/data/SGPstateData.rda and b/data/SGPstateData.rda differ