R/getMyLabel.R

Defines functions `getMyLabel`

`getMyLabel` <-
function(state,
	content_area,
	year,
	label="Cutscores") {

	tmp.cutscore.years <- unlist(lapply(sapply(strsplit(grep(content_area, names(SGP::SGPstateData[[state]][["Achievement"]][[label]]), value=TRUE), "[.]"), tail, -1), paste, collapse="."))
	tmp.cutscore.years[tmp.cutscore.years==""] <- NA
	if (any(!is.na(tmp.cutscore.years))) {
		if (year %in% tmp.cutscore.years) {
			return(paste(content_area, year, sep="."))
		} else {
			if (year==sort(c(year, tmp.cutscore.years))[1]) {
				return(content_area)
			} else {
				return(paste(content_area, sort(tmp.cutscore.years)[which(year==sort(c(year, tmp.cutscore.years)))-1], sep="."))
			}
		}
	} else {
		return(content_area)
	}
} ## END getMyLabel Function

Try the SGP package in your browser

Any scripts or data that you put into this service are public.

SGP documentation built on Oct. 23, 2023, 5:08 p.m.