- stations = unique(stations)
- Ka = length(expertsArray)
- Sa = length(stationsArray)
- if (length(experts) > Ka)
- stop("Too many experts specified: at least one of them does not exist")
- if (length(stations) > Sa)
- stop("Too many stations specified: at least one of them does not exist")
- if (is.numeric(experts) && any(experts > Ka))
- stop(paste("Some experts indices are higher than the maximum which is", Ka))
- if (is.numeric(stations) && any(stations > Sa))
- stop(paste("Some stations indices are higher than the maximum which is", Sa))
- if (is.character(experts))
- {
- expertsMismatch = (1:Ka)[! experts %in% expertsArray]
- if (length(expertsMismatch) > 0)
- stop(cat(paste("Typo in experts names:", experts[expertsMismatch]), sep="\n"))
- }
- if (is.character(stations))
- {
- stationsMismatch = (1:Sa)[! stations %in% stationsArray]
- if (length(stationsMismatch) > 0)
- stop(cat(paste("Typo in stations names:", stations[stationsMismatch]), sep="\n"))
- }
- if (!is.character(experts))
- experts = expertsArray[experts]
- if (!is.character(stations))
- stations = stationsArray[stations]