Thanks for providing code. Could you kindly take further steps to make it easier for other forum users to help you? Share some representative data that will enable your code to run and show the problematic behaviour.
How do I share data for a reprex?
You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.
I know why I had an issue. It was because there is no data/value for target. I haven't use R before and this is the first time, but I need to use a condition saying If no target value, don't display scatter plot.
test_ok <- function (x) {
#adapted from shiny::isTruthy()
if (inherits(x, "try-error"))
return(FALSE)
if (!is.atomic(x))
return(TRUE)
if (is.null(x))
return(FALSE)
if (length(x) == 0)
return(FALSE)
if (all(is.na(x)))
return(FALSE)
if (is.character(x) && !any(nzchar(stats::na.omit(x))))
return(FALSE)
if (is.logical(x) && !any(stats::na.omit(x)))
return(FALSE)
return(TRUE)
}
if(test_ok(dataset$Mn_Target)){
# do your code here , given that its ok to do so
print("im fine")
}