I'm trying to eliminate the unwanted datavalues in my dataset. For example, there is a "five" where there should only be numeric variables and thats what I'm trying to solve currently. From what I've learned I should be able to do it with the code below but I cannot get it to work.
sorghum_clean <- sorghum |>
mutate (
k = case_when(
k == "five" ~ k,
k ~ TRUE)
)
I get the error as follows:
Error in mutate()
: In argument:
k = case_when(is.na(k) ~ k, k ~ TRUE)
. Caused by error in case_when()
: ! ..2 (left)
must be a logical vector, not a double vector. Backtrace: 1. dplyr::mutate(...) 8. dplyr::case_when(is.na(k) ~ k, k ~ TRUE, .default = NULL, .ptype = NULL, .size = NULL)
[image] Show Traceback
Error in mutate(sorghum, k = as.numeric(k), k = case_when(is.na(k) ~ k, : Caused by error in case_when()
: ! ..2 (left)
must be a logical vector, not a double vector.