title: Create new column in R dataframe with values in other columns
body: <p>My R dataframe's headers include Forward, Backward, SideLeft, SideRight, and the new column I am trying to create is the Direction column.</p>
  
  <p>The columns started with just TRUE/FALSE values, and I converted the TRUE values into the header names and made them all characters.  </p>
  
  <pre><code>df[df==TRUE] &lt;- colnames(df)[which(df==TRUE, arr.ind=TRUE)[,'col']]
  </code></pre>
  
  <p>Below is what the dataframe looks like: </p>
  
  <pre><code>&gt; df
      For  Back SLeft SRight Direction
  1   For FALSE FALSE  FALSE     FALSE
  2 FALSE FALSE SLeft  FALSE     FALSE
  3 FALSE  Back FALSE  FALSE     FALSE
  4 FALSE FALSE FALSE SRight     FALSE
  </code></pre>
  
  <p>What I am trying to produce:</p>
  
  <pre><code>&gt; df
      For  Back SLeft SRight Direction
  1   For FALSE FALSE  FALSE       For
  2 FALSE FALSE SLeft  FALSE     SLeft
  3 FALSE  Back FALSE  FALSE      Back
  4 FALSE FALSE FALSE SRight    SRight
  </code></pre>
  
  <p>With this code:</p>
  
  <pre><code>for (i in df){
    for (index in 1:length(i)){
      if (i[index]!="FALSE"){
        df$Direction[i] = i[index]
      }
    }
  }
  </code></pre>
  
  <p>What I am getting:</p>
  
  <pre><code>&gt; df
      For  Back SLeft SRight Direction
  1   For FALSE FALSE  FALSE     FALSE
  2 FALSE FALSE SLeft  FALSE     FALSE
  3 FALSE  Back FALSE  FALSE     FALSE
  4 FALSE FALSE FALSE SRight     FALSE
  </code></pre>
  
  <p>First post, have mercy on my description/edits</p>