title: Automatically fill a column in a dataframe in R with "coordinates"
body: <p>Starting with the Dataframe y:</p>
  
  <pre><code>x &lt;- c(2,NA,6,8,9,10)
  y &lt;- data.frame(letters[1:6], 1:6, NA, 3:8, NA, x, NA)
  colnames(y) &lt;- c("Patient", "C1", "First_C1", "C2", "First_C2", "C3", "First_C3")
  </code></pre>
  
  <p>I want R to look at each element of C1, find out the first patient (first row) with that element and the identify in which column it is, and add the "coordinates" "Patient_Column" to First_element_C1... Then, do the same with C2 and C3.</p>
  
  <p>So, the result should be this:</p>
  
  <pre><code>y$First_C1 &lt;- c("a_C1", "a_C3", "a_C2", "b_C2", "c_C2", "c_C3")
  y$First_C2 &lt;- c("a_C2", "b_C2", "c_C2", "c_C3", "e_C2", "d_C3")
  y$First_C3 &lt;- c("a_C3", NA, "c_C3", "d_C3", "e_C3", "f_C3")
  </code></pre>
  
  <p>I dont know how to write the code, not even how to search for it... Could someone help me here?</p>