https://github.com/cran/kohonen
Tip revision: f55147dbc00e909dd2d71d60e2931790055ce14d authored by Ron Wehrens on 15 March 2017, 12:14:29 UTC
version 3.0.0
version 3.0.0
Tip revision: f55147d
check.whatmap.R
check.whatmap <- function(x, whatmap)
{
whatmap <- unique(whatmap)
checkpar <- NULL
if (class(x) == "kohonen") {
checkpar <- getCodes(x)
} else {
if (is.list(x)) # not foolproof!
checkpar <- x
}
if (is.null(checkpar))
stop("no possibility to check argument 'whatmap'!")
if (is.null(whatmap)) {
if (is.null(x$whatmap)) {
return(1:length(checkpar)) # no selection, return all layers
} else {
return(x$whatmap)
}
}
if (is.numeric(whatmap) && all(whatmap %in% 1:length(checkpar)))
return(sort(whatmap))
if (is.character(whatmap)) {
idx <- match(whatmap, names(checkpar)) ## works also when comparing to NULL
if (any(!is.na(idx)))
return(sort(idx))
}
stop("incorrect whatmap argument") # invalid selection
}