How would I trap an error in an argument passed to a function and simply quit the function? I have tried stop, but it sends me to debug the program. A user should enter a vector but they have a dataframe and rather than type in df$temp they forgot the $temp part.
my_func <- function(my_var){
if(is.data.frame(my_var)) {stop("Please pass me a vector not a ",class(my_var))
} else {
print(my_var)
}
}
my_func(gapminder)
I want the message printed in the console, but I want to suppress the debug feature.