-2

I have a dataset combi, and I want to impute all the values of item_visibility columns that have zeros with the median of the item_visibility values corresponding outlet_size column which has three categories "high" "small" and "medium" respectively in R. I know that we should use the dplyr groupy and summarize function. I'm lost after that.

  • 2
    Welcome to Stack Overflow, please read [this post](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and edit your question as suggested for reproducibility. – NelsonGon Feb 22 '19 at 12:12

1 Answers1

0

This should work:

data %>%
  group_by(outlet_size) %>%
  mutate(item_visibility = ifelse(0,median(item_visibility),item_visibility))
Just Burfi
  • 159
  • 9