I'm wondering why, when running the below R function, I get the following warning:
Warning message: In if (is.na(labels)) axTicks(2) else labels : the condition has length > 1 and only the first element will be used
Since everything works fine except this warning message, I was wondering how I could eliminate this warning message?
bb <- function(labels = NA){
plot(1, yaxt = "n")
lab <- if(is.na(labels)) axTicks(2) else labels ## Why this gives a warning message?
axis(2, at = axTicks(2), labels = lab)
}
# Example of use:
bb(labels = paste0("Hi ", 1:5))
Aucun commentaire:
Enregistrer un commentaire