Bar Chart Drill down

Hi,

The mutate function is part of the dplyr package from the Tidyverse. This is an alternative way of writing the flow of your R code and provides a great set of tools for powerful data manipulations while enhancing the readability of your code.

It can indeed look a bit daunting at first (it was for me too), but it's very handy once you get the hang of it. Most functions from tidyverse have an R counterpart that you could use. In case of the mutate, it's just updating a specific column.

library(dplyr)

myData = data.frame(x = 1:10, y = LETTERS[1:10])

#Using plain R
myResult = myData
myResult[, "x"] = myResult[, "x"] + 1
myResult[myResult$x > 5, "y"] = "Z"
myResult
#>     x y
#> 1   2 A
#> 2   3 B
#> 3   4 C
#> 4   5 D
#> 5   6 Z
#> 6   7 Z
#> 7   8 Z
#> 8   9 Z
#> 9  10 Z
#> 10 11 Z

#Using mutate from dplyr
myResult = myData %>% 
  mutate(x = x + 1, y = ifelse(x > 5, "Z", x))
myResult
#>     x y
#> 1   2 2
#> 2   3 3
#> 3   4 4
#> 4   5 5
#> 5   6 Z
#> 6   7 Z
#> 7   8 Z
#> 8   9 Z
#> 9  10 Z
#> 10 11 Z

Created on 2020-07-30 by the reprex package (v0.3.0)

It's not very clear for me what your data looks like, as you have not provided me a reprex. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:

So if you give a a bit more detail and code on the issue, I'll try and help you further.

PJ