My Code:
complete_sales <- complete_sales %>%
mutate(
imputed_purchases = if_else(is.na(total_purchased),
purchase_mean,
total_purchased)
)
What I expected to happen:
A new column named imputed purchases would be created and the NA values would be replaced with the purchase mean.
What actually happened:
Error: Problem with `mutate()` input `imputed_purchases`.
x `false` must be a double vector, not an integer vector.
ℹ Input `imputed_purchases` is `if_else(is.na(total_purchased), purchase_mean, total_purchased)`.
This is literally the code from the solution, and it still will not work for me. I know it is because the if_else function is seeing purchase_mean and total_purchased as two different class types, but how do I fix this? ?