I'm trying to get the names of the elements in a vector with some priorities.
If there is any element with value "integer", get the name of the first of such elements (in the example below, year)
But if there is no element with value "integer", then do the same thing with any element with value "numeric".
I have tried the following without success (this is a toy example a functional answer is appreciated):
cl <- c(group = "character", degree = "numeric", year = "integer", zoo = "integer")
names(cl[cl == "integer" || cl == "numeric"])[1]
desired.output = "year"