Skip to content

Commit 8906c2a

Browse files
authored
Merge pull request #1238 from dbetebenner/master
Several updates for 1.9 push to CRAN. See individual pull requests for details
2 parents 602a05e + d0b7763 commit 8906c2a

File tree

162 files changed

+1299
-726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+1299
-726
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: SGP
22
Type: Package
33
Title: Student Growth Percentiles & Percentile Growth Trajectories
4-
Version: 1.9-0.10
5-
Date: 2019-2-14
4+
Version: 1.9-0.0
5+
Date: 2019-2-19
66
Authors@R: c(person(given=c("Damian", "W."), family="Betebenner", email="[email protected]", role=c("aut", "cre")),
77
person(given=c("Adam", "R."), family="Van Iwaarden", email="[email protected]", role="aut"),
88
person(given="Ben", family="Domingue", email="[email protected]", role="aut"),
@@ -74,7 +74,7 @@ Authors@R: c(person(given=c("Damian", "W."), family="Betebenner", email="dbetebe
7474
Maintainer: Damian W. Betebenner <[email protected]>
7575
Depends: R (>= 3.0)
7676
Suggests: SGPdata (>= 21.0-0), knitr, rmarkdown
77-
Imports: Cairo, colorspace, crayon, datasets, data.table (>= 1.10.0), digest, doParallel, doRNG, equate (>= 2.0-5), foreach, graphics, grid, grDevices, gridBase, iterators, gtools, jsonlite, matrixStats, methods, parallel, plotly, quantreg, RSQLite, randomNames (>= 0.0-5), sn (>= 1.0-0), splines, stats, toOrdinal, utils
77+
Imports: Cairo, colorspace, crayon, datasets, data.table (>= 1.12.0), digest, doParallel, doRNG, equate (>= 2.0-5), foreach, graphics, grid, grDevices, gridBase, iterators, gtools, jsonlite, matrixStats, methods, parallel, plotly, quantreg, RSQLite, randomNames (>= 0.0-5), sn (>= 1.0-0), splines, stats, toOrdinal, utils
7878
Description: Functions to calculate student growth percentiles and percentile growth projections/trajectories for students using large scale,
7979
longitudinal assessment data. Functions use quantile regression to estimate the conditional density associated
8080
with each student's achievement history. Percentile growth projections/trajectories are calculated using the coefficient matrices derived from

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Update of web-based documentation (https://sgp.io)
66
* Various state meta-data updates
7+
* Adding functionality to return number of years to reach SGP_TARGET returned. Accessible through SGPstateData meta-data currently. See testSGP(3) source code for example.
78

89

910
# SGP 1.8-0.0

R/abcSGP.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,6 @@ function(sgp_object,
216216

217217
### Print finish and return SGP object
218218

219-
messageSGP(paste("Finished abcSGP", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
219+
messageSGP(paste("Finished abcSGP", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
220220
return(sgp_object)
221221
} ## END abcSGP Function

R/analyzeSGP.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ function(sgp_object,
22302230

22312231
if (!is.null(sgp.test.cohort.size) & toupper(return.sgp.test.results) != "ALL_DATA") {
22322232
if (!return.sgp.test.results) {
2233-
messageSGP(paste("Finished analyzeSGP", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
2233+
messageSGP(paste("Finished analyzeSGP", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
22342234
return(sgp_object)
22352235
} else {
22362236
setkeyv(tmp_sgp_data_for_analysis, getKey(sgp_object@Data))
@@ -2243,6 +2243,6 @@ function(sgp_object,
22432243
if (goodness.of.fit.print) gof.print(sgp_object)
22442244
setkeyv(sgp_object@Data, getKey(sgp_object)) # re-key data for combineSGP, etc.
22452245
sgp_object@Version[["analyzeSGP"]][[as.character(gsub("-", "_", Sys.Date()))]] <- as.character(packageVersion("SGP"))
2246-
messageSGP(paste("Finished analyzeSGP", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
2246+
messageSGP(paste("Finished analyzeSGP", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
22472247
return(sgp_object)
22482248
} ## END analyzeSGP Function

R/baselineSGP.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function(sgp_object,
140140

141141
message(paste("\tStarted baselineSGP Coefficient Matrix Calculation:", started.date))
142142
message(paste0("\tContent Area: ", tail(content_areas, 1), ", Grade Progression: ", paste(grade.sequences, collapse=", "), ". "))
143-
message(paste0("\tFinished baselineSGP Coefficient Matrix Calculation ", prettyDate(), " in ", convertTime(timetaken(started.at)), ".\n"))
143+
message(paste0("\tFinished baselineSGP Coefficient Matrix Calculation ", prettyDate(), " in ", convertTime(timetakenSGP(started.at)), ".\n"))
144144

145145
return(tmp_sgp_list)
146146

@@ -300,7 +300,7 @@ function(sgp_object,
300300
###
301301
############################################################
302302

303-
message(paste("\tFinished baselineSGP", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
303+
message(paste("\tFinished baselineSGP", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
304304

305305
if (return.matrices.only) {
306306
tmp.list <- list()

R/bubblePlot_Styles.R

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ if (1 %in% bPlot.styles) {
368368
} ## End loop over content_area.iter
369369
} ## End loop over year.iter
370370

371-
message(paste("\tFinished bubblePlot Style 1", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
371+
message(paste("\tFinished bubblePlot Style 1", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
372372

373373
} ## END bubblePlot style 1
374374

@@ -498,7 +498,7 @@ if (2 %in% bPlot.styles) {
498498
} ## End loop over year.iter
499499
} ## End loop over bPlot.levels.iter
500500

501-
message(paste("\tFinished bubblePlot Style 2", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
501+
message(paste("\tFinished bubblePlot Style 2", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
502502

503503
} ## END bubblePlot style 2
504504

@@ -616,7 +616,7 @@ if (3 %in% bPlot.styles) {
616616
} ## End loop over content_area.iter
617617
} ## End loop over year.iter
618618

619-
message(paste("\tFinished bubblePlot Style 3", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
619+
message(paste("\tFinished bubblePlot Style 3", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
620620

621621
} ## END bubblePlot style 3
622622

@@ -714,7 +714,7 @@ if (10 %in% bPlot.styles) {
714714
} ## End loop over content_area.iter
715715
} ## End loop over year.iter
716716

717-
message(paste("\tFinished bubblePlot Style 10", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
717+
message(paste("\tFinished bubblePlot Style 10", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
718718

719719
} ## END bubblePlot style 10
720720

@@ -850,7 +850,7 @@ if (10 %in% bPlot.styles) {
850850
} ## End loop over year.iter
851851
} ## End loop over bPlot.levels.iter
852852

853-
message(paste("\tFinished bubblePlot Style 11", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
853+
message(paste("\tFinished bubblePlot Style 11", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
854854

855855
} ## END bubblePlot style 11
856856

@@ -948,7 +948,7 @@ if (20 %in% bPlot.styles) {
948948
} ## End loop over content_area.iter
949949
} ## End loop over year.iter
950950

951-
message(paste("\tFinished bubblePlot Style 20", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
951+
message(paste("\tFinished bubblePlot Style 20", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
952952

953953
} ## END bubblePlot style 20
954954

@@ -1068,7 +1068,7 @@ if (21 %in% bPlot.styles) {
10681068
} ## End loop over content_area.iter
10691069
} ## End loop over year.iter
10701070

1071-
message(paste("\tFinished bubblePlot Style 21", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
1071+
message(paste("\tFinished bubblePlot Style 21", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
10721072

10731073
} ## END bubblePlot style 21
10741074

@@ -1194,7 +1194,7 @@ if (22 %in% bPlot.styles) {
11941194
} ## End loop over content_area.iter
11951195
} ## End loop over year.iter
11961196

1197-
message(paste("\tFinished bubblePlot Style 22", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
1197+
message(paste("\tFinished bubblePlot Style 22", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
11981198

11991199
} ## END bubblePlot style 22
12001200

@@ -1292,7 +1292,7 @@ if (22 %in% bPlot.styles) {
12921292
} ## End loop over school_number.iter
12931293
} ## End loop over year.iter
12941294

1295-
message(paste("\tFinished bubblePlot Style 50", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
1295+
message(paste("\tFinished bubblePlot Style 50", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
12961296

12971297
} ## END bubblePlot style 50
12981298

@@ -1389,7 +1389,7 @@ if (22 %in% bPlot.styles) {
13891389
} ## End loop over content_area.iter
13901390
} ## End loop over year.iter
13911391

1392-
message(paste("\tFinished bubblePlot Style 53", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
1392+
message(paste("\tFinished bubblePlot Style 53", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
13931393

13941394
} ## END bubblePlot style 53
13951395

@@ -1545,7 +1545,7 @@ if (22 %in% bPlot.styles) {
15451545
} ## End loop over year.iter
15461546
} ## End loop over bPlot.levels.iter
15471547

1548-
message(paste("\tFinished bubblePlot Style 55", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
1548+
message(paste("\tFinished bubblePlot Style 55", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
15491549

15501550
} ## END bubblePlot style 55
15511551

@@ -1645,7 +1645,7 @@ if (22 %in% bPlot.styles) {
16451645
} ## End loop over content_area.iter
16461646
} ## End loop over year.iter
16471647

1648-
message(paste("\tFinished bubblePlot Style 57", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
1648+
message(paste("\tFinished bubblePlot Style 57", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
16491649

16501650
} ## END bubblePlot style 57
16511651

@@ -1799,7 +1799,7 @@ if (22 %in% bPlot.styles) {
17991799
} ## End loop over year.iter
18001800
} ## End loop over bPlot.levels.iter
18011801

1802-
message(paste("\tFinished bubblePlot Style 59", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
1802+
message(paste("\tFinished bubblePlot Style 59", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
18031803

18041804
} ## END bubblePlot style 59
18051805

@@ -2022,7 +2022,7 @@ if (22 %in% bPlot.styles) {
20222022
} ## END content_area.iter loop
20232023
} ## END year.iter loop
20242024

2025-
message(paste("\tFinished bubblePlot Style 100", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
2025+
message(paste("\tFinished bubblePlot Style 100", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
20262026

20272027
} ## END if bubblePlot style 100
20282028

@@ -2187,7 +2187,7 @@ if (22 %in% bPlot.styles) {
21872187
} ## END content_area.iter loop
21882188
} ## END year.iter loop
21892189

2190-
message(paste("\tFinished bubblePlot Style 150", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
2190+
message(paste("\tFinished bubblePlot Style 150", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
21912191

21922192
} ## END if bubblePlot style 150
21932193

@@ -2366,7 +2366,7 @@ if (22 %in% bPlot.styles) {
23662366
} ## END content_area.iter loop
23672367
} ## END year.iter loop
23682368

2369-
message(paste("\tFinished bubblePlot Style 153", prettyDate(), "in", convertTime(timetaken(started.at)), "\n"))
2369+
message(paste("\tFinished bubblePlot Style 153", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n"))
23702370

23712371
} ## END if bubblePlot style 153
23722372

R/combineSGP.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ function(
119119
sgp.target.scale.scores.merge <- SGP::SGPstateData[[state]][["SGP_Configuration"]][["sgp.target.scale.scores.merge"]]
120120
}
121121

122+
### Check return.target.num.years
123+
124+
if (!is.null(SGP::SGPstateData[[state]][["SGP_Configuration"]][["return.sgp.target.num.years"]])) {
125+
return.sgp.target.num.years <- SGP::SGPstateData[[state]][["SGP_Configuration"]][["return.sgp.target.num.years"]]
126+
} else return.sgp.target.num.years <- FALSE
127+
128+
129+
122130

123131
### Utility functions
124132

@@ -400,7 +408,7 @@ function(
400408
invisible(slot.data[, paste0("SCALE_SCORE_PRIOR_", tmp.prior-1L) := as.numeric(sapply(tmp.split, function(x) rev(x)[tmp.prior]))])
401409
}}}
402410

403-
tmp.data <- getTargetSGP(sgp_object, slot.data, content_areas, state, years, target.type.iter, target.level.iter, max.sgp.target.years.forward, fix.duplicates=fix.duplicates)
411+
tmp.data <- getTargetSGP(sgp_object, slot.data, content_areas, state, years, target.type.iter, target.level.iter, max.sgp.target.years.forward, fix.duplicates=fix.duplicates, return.sgp.target.num.years=return.sgp.target.num.years)
404412

405413
if (!is.null(fix.duplicates)) dup.by <- c(key(tmp.data), grep("SCALE_SCORE$|SCALE_SCORE_PRIOR", names(tmp.data), value=TRUE)) else dup.by <- key(tmp.data)
406414

@@ -644,7 +652,7 @@ function(
644652
setkeyv(slot.data, getKey(slot.data))
645653
sgp_object@Data <- slot.data
646654

647-
messageSGP(c(tmp.messages, paste("Finished combineSGP", prettyDate(), "in", convertTime(timetaken(started.at)), "\n")))
655+
messageSGP(c(tmp.messages, paste("Finished combineSGP", prettyDate(), "in", convertTime(timetakenSGP(started.at)), "\n")))
648656

649657
return(sgp_object)
650658
} ## END combineSGP Function

R/convertTime.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
`convertTime` <-
22
function(tmp.time) {
3-
# tmp <- tail(c(0, 0, rev(as.numeric(rev(unlist(strsplit(sub("sec", "", tmp.time), ":")))))), 3)
4-
tmp <- tail(c(0, 0, 0, rev(as.numeric(rev(unlist(strsplit(sub(" ", ":", sub("sec|days ", "", tmp.time)), ":")))))), 4)
3+
tmp <- tail(c(0, 0, 0, as.numeric(unlist(strsplit(tmp.time, ":")))), 4)
54
tmp.label <- c("Day", "Hour", "Minute", "Second")
65
tmp.label[which(tmp!=1)] <- paste0(tmp.label, "s")[which(tmp!=1)]
76
return(paste(paste(tmp[tmp!=0], tmp.label[tmp!=0]), collapse=", "))

R/getSGPConfig.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ function(sgp_object,
2222
year.for.equate=NULL,
2323
sgp.percentiles.equated=FALSE,
2424
SGPt=NULL,
25-
projection_group.identifier=NULL) {
25+
projection_group.identifier=NULL,
26+
from.getTargetScaleScore=FALSE) {
2627

2728
YEAR <- CONTENT_AREA <- VALID_CASE <- NULL
2829

@@ -60,7 +61,7 @@ function(sgp_object,
6061

6162
### get.config function
6263

63-
get.config <- function(content_area, year, grades) {
64+
get.config <- function(content_area, year, grades, from.getTargetScaleScore) {
6465

6566
### Data for Years & Grades
6667
tmp.unique.data <- lapply(sgp_object@Data[SJ("VALID_CASE", content_area), nomatch=0][, c("YEAR", "GRADE"), with=FALSE], function(x) sort(type.convert(unique(x), as.is=TRUE)))
@@ -76,6 +77,11 @@ function(sgp_object,
7677
if (!is.numeric(tmp.last.year.grades) | !is.numeric(tmp.unique.data[['GRADE']])) {
7778
stop("\tNOTE: Automatic 'sgp.config' calculation is only available for integer grade levels. Manual specification of 'sgp.config' is required for non-traditional grade and course progressions.")
7879
}
80+
81+
if (from.getTargetScaleScore && length(tmp.last.year.grades) > length(grades)) {
82+
grades <- c(sort(grades), tmp.last.year.grades[which(tmp.last.year.grades==tail(sort(grades),1))+1])
83+
}
84+
7985
tmp.sgp.grade.sequences <- lapply(tmp.last.year.grades, function(x) tail(tmp.unique.data$GRADE[tmp.unique.data$GRADE <= x], length(tmp.unique.data$YEAR)))
8086
if (!is.null(grades)) {
8187
tmp.sgp.grade.sequences <- tmp.sgp.grade.sequences[sapply(tmp.sgp.grade.sequences, function(x) tail(x,1)) %in% grades]
@@ -523,7 +529,7 @@ function(sgp_object,
523529
}
524530
for (i in content_areas) {
525531
for (j in tmp.years[[i]]) {
526-
tmp.sgp.config[[paste(i,j,sep=".")]] <- get.config(i,j,grades)
532+
tmp.sgp.config[[paste(i,j,sep=".")]] <- get.config(i,j,grades,from.getTargetScaleScore)
527533
}
528534
}
529535
par.sgp.config <- checkConfig(get.par.sgp.config(tmp.sgp.config), "Standard")

R/getTargetSGP.R

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ function(sgp_object,
99
max.sgp.target.years.forward=3,
1010
subset.ids=NULL,
1111
return.lagged.status=TRUE,
12-
fix.duplicates=fix.duplicates) {
12+
fix.duplicates=fix.duplicates,
13+
return.sgp.target.num.years=FALSE) {
1314

1415
VALID_CASE <- ID <- CONTENT_AREA <- YEAR <- GRADE <- FIRST_OBSERVATION <- LAST_OBSERVATION <- STATE <- SGP_PROJECTION_GROUP <- DUPS_FLAG <- SCALE_SCORE <- SCALE_SCORE_PRIOR <- V1 <- NULL
1516

1617
### Utility functions
1718

18-
getTargetSGP_INTERNAL <- function(tmp_object_1, state, state.iter, projection_group.iter, target.type, target.level, year_within, fix.duplicates, max.sgp.target.years.forward) {
19+
getTargetSGP_INTERNAL <- function(tmp_object_1, state, state.iter, projection_group.iter, target.type, target.level, year_within, fix.duplicates, max.sgp.target.years.forward, return.sgp.target.num.years) {
1920

2021
if (dups.tf <- !is.null(fix.duplicates)) {
2122
if (any(grepl("_DUPS_[0-9]*", tmp_object_1[["ID"]]))) {
@@ -111,16 +112,25 @@ function(sgp_object,
111112
paste(grep(paste0(sgp.projections.projection.unit.label, "_[", paste(seq(num.years.to.get), collapse=""), "]", tmp.suffix), names(tmp_object_1), value=TRUE), collapse=", ")
112113

113114
jExpression <- parse(text=paste0("{catch_keep_move_functions[[unclass(", target.level, "_STATUS_INITIAL)]](", tmp.level.variables, ", na.rm=TRUE)}"))
115+
jExpression_num_years <- parse(text=paste0("{catch_keep_move_functions_num_years[[unclass(", target.level, "_STATUS_INITIAL)]](c(", tmp.level.variables, "))}"))
114116
if (dups.tf) { # Re-create _DUPS_ labels since ID is in jExp_Key
115117
if ("DUPS_FLAG" %in% names(tmp_object_1)) invisible(tmp_object_1[!is.na(DUPS_FLAG), ID := paste0(ID, "_DUPS_", DUPS_FLAG)])
116118
setkeyv(tmp_object_1, getKey(tmp_object_1))
117119
jExp_Key <- intersect(names(tmp_object_1), c(jExp_Key, grep("SCALE_SCORE$|SCALE_SCORE_PRIOR", names(tmp_object_1), value=TRUE), "DUPS_FLAG", "SGP_PROJECTION_GROUP_SCALE_SCORES")) # Keep these vars - still unique by ID so doesn't change results
118120
}
119121

120122
if (max.sgp.target.years.forward.iter==1L) {
121-
tmp_object_2 <- tmp_object_1[, eval(jExpression), keyby = jExp_Key]
123+
if (return.sgp.target.num.years) {
124+
tmp_object_2 <- tmp_object_1[, list(eval(jExpression), eval(jExpression_num_years)), keyby = jExp_Key]
125+
} else {
126+
tmp_object_2 <- tmp_object_1[, eval(jExpression), keyby = jExp_Key]
127+
}
122128
} else {
123-
tmp_object_2[,V1:=tmp_object_1[, eval(jExpression), keyby = jExp_Key][['V1']]]
129+
if (return.sgp.target.num.years) {
130+
tmp_object_2[,c('V1', 'V2'):=list(tmp_object_1[, eval(jExpression), keyby = jExp_Key][['V1']], tmp_object_1[, eval(jExpression_num_years), keyby = jExp_Key][['V1']])]
131+
} else {
132+
tmp_object_2[,V1:=tmp_object_1[, eval(jExpression), keyby = jExp_Key][['V1']]]
133+
}
124134
}
125135

126136
if (target.type %in% c("sgp.projections.baseline", "sgp.projections.lagged.baseline")) baseline.label <- "_BASELINE" else baseline.label <- NULL
@@ -129,6 +139,10 @@ function(sgp_object,
129139

130140
setnames(tmp_object_2, "V1",
131141
paste0("SGP_TARGET", baseline.label, target.level.label, "_", num.years.to.get.label, "_", sgp.projections.projection.unit.label, projection.label))
142+
if (return.sgp.target.num.years) {
143+
setnames(tmp_object_2, "V2",
144+
paste0("SGP_TARGET", baseline.label, target.level.label, "_", num.years.to.get.label, "_", sgp.projections.projection.unit.label, projection.label, "_NUM_YEARS_TO_TARGET"))
145+
}
132146

133147
if (target.type %in% c("sgp.projections.lagged", "sgp.projections.lagged.baseline") && return.lagged.status) {
134148
tmp_object_2[,c("ACHIEVEMENT_LEVEL_PRIOR", grep("STATUS_INITIAL", names(tmp_object_1), value=TRUE)):=
@@ -147,6 +161,7 @@ function(sgp_object,
147161
tmp.sgpTarget.list <- list()
148162

149163
catch_keep_move_functions <- c(min, max)
164+
catch_keep_move_functions_num_years <- c(which.min, which.max)
150165

151166
if (!is.null(SGP::SGPstateData[[state]][["SGP_Configuration"]][["sgp.projections.projection.unit.label"]])) {
152167
sgp.projections.projection.unit.label <- SGP::SGPstateData[[state]][["SGP_Configuration"]][["sgp.projections.projection.unit.label"]]
@@ -201,7 +216,7 @@ function(sgp_object,
201216
for (projection_group.iter in unique(tmp_object_1[['SGP_PROJECTION_GROUP']])) {
202217
tmp.sgpTarget.list[[paste(state.iter, projection_group.iter, sep=".")]] <-
203218
getTargetSGP_INTERNAL(tmp_object_1[SGP_PROJECTION_GROUP==projection_group.iter], state, state.iter, projection_group.iter, target.type, target.level,
204-
year_within="YEAR_WITHIN" %in% names(slot.data), fix.duplicates=fix.duplicates, max.sgp.target.years.forward=max.sgp.target.years.forward)
219+
year_within="YEAR_WITHIN" %in% names(slot.data), fix.duplicates=fix.duplicates, max.sgp.target.years.forward=max.sgp.target.years.forward, return.sgp.target.num.years=return.sgp.target.num.years)
205220
}
206221
} ### END !is.null(level.to.get)
207222
} ### END for state.iter

0 commit comments

Comments
 (0)