title: How do I add a tibble column assigning values for groups of values from another variable?
body: <p>I'm trying to create a new column in my tibble that assigns one value for a group of factor levels in another column. 
  For example, in a tibble where variable "time" has the values "t1", "t2", "t3", "t4", "t5", and "t6", how can I create variable B which categorises these values as "X" if A = t1, t2, or t3, or "Y" if A = t4, t5, or t6.</p>
  
  <p>I'm working with tidyverse, and as it's for a homework problem I assume that it should be doable with dplyr (all the other problems in the set require deplyr). I tried using if‐else branching, like in the code below, but I get the error "comparison (1) is possible only for atomic and list types"</p>
  
  <pre><code>install.packages("tidyverse")
  library("tidyverse")
  
  #data originally came from a csv file but I've reproduced a similar example tibble here:
  
  t &lt;- c("t1", "t2", "t3", "t4", "t5", "t6")
  tb &lt;- tibble(x = 1:20, time = sample(t, length(x), replace = TRUE))
  
  if(time == c("t1", "t2", "t3")) {
      tb &lt;- mutate(tb, B = "X")
    } else {
      tb &lt;- mutate(tb, B = "Y")
    }
  </code></pre>
  
  <p>I'm pretty new to R so I have no clue what to even change to get rid of the error (though I'm sure there's other things wrong with the code beyond that). I basically just want to end up with the same tibble but with an extra column B, where B = X for all cases where time is t1:t3 and B =Y otherwise.</p>