title: Merging r dataset columns by copying rows
body: <p>I have a dataset with 7 columns. One of the columns shows course cluster numbers (1-9, can have multiple numbers, like 1,4,5,6), and there are 3 columns (AH, SS, QS) that have logical value depending on the cluster number: if there is a number in 1-3 then the 1st column is True and so on. Here is the structure:</p>
  <pre><code>'data.frame':   213 obs. of  7 variables:
   $ Major       : chr  &quot;BUS&quot; &quot;BUS&quot; &quot;BUS&quot; &quot;BUS&quot; ...
   $ CourseNumber: chr  &quot;101&quot; &quot;105&quot; &quot;109&quot; &quot;110&quot; ...
   $ Title       : chr  &quot;Introduction to Business&quot; &quot;Foundations of Management&quot; &quot;Business Math&quot; &quot;Applied Statistics&quot; ...
   $ Number      : chr  &quot;4, 5&quot; &quot;5&quot; &quot;7, 8, 9&quot; &quot;7, 8, 9&quot; ...
   $ AH          : logi  FALSE FALSE FALSE FALSE TRUE FALSE ...
   $ SS          : logi  TRUE TRUE FALSE FALSE TRUE TRUE ...
   $ QS          : logi  FALSE FALSE TRUE TRUE FALSE FALSE ...
  </code></pre>
  <p>I want to merge the last 3 columns into 1 column like this: if, for example, the values for AH, SS, QS are T, T, F,  the row will be copied into 2, where in one row the data will be AH, in the second row - SS.</p>