sales <- sales %>% filter(! (is.na(sales[["user_submitted_review"]]))) total_purchased_mean <- mean(sales[["total_purchased"]], na.rm = T) sales_up <- sales %>% mutate(updated_total_purchased = if_else(is.na(total_purchased), total_purchased_mean, total_purchased))
What I expected to happen: I expected this to replace the corresponding row with ‘na’ in the total_purchased column with the mean of the total_purchased
What actually happened:
Error : x `false` must be a double vector not an integer vector
I’m confused, should I cast the total_purchased_mean as an integer.