title: How to stack a dataframe in R
body: <p>I have a data frame that I would like to stack in R so that I end up with three columns. Below cis some example data in its current format. </p>
  
  <pre><code>&gt; dput(df)
  structure(list(Day = c("d1", "d2", "d3", "d4", "d5", "d6", "d7", 
  "d8", "d9", "d10"), A1 = c(14L, 24L, 22L, NA, NA, NA, NA, NA, 
  NA, NA), A2 = c(9L, 15L, 34L, 2L, 12L, 34L, 234L, 34L, NA, NA
  ), A3 = c(3L, 4L, 19L, 76L, 34L, 34L, 23L, 24L, 37L, 44L), A1.1 = c(34L, 
  55L, 75L, 12L, 56L, 35L, 3L, 22L, NA, NA)), .Names = c("Day", 
  "A1", "A2", "A3", "A1.1"), class = "data.frame", row.names = c(NA, 
  -10L))
  
  &gt; df
     Day A1  A2 A3 A1.1
  1   d1 14   9  3   34
  2   d2 24  15  4   55
  3   d3 22  34 19   75
  4   d4 NA   2 76   12
  5   d5 NA  12 34   56
  6   d6 NA  34 34   35
  7   d7 NA 234 23    3
  8   d8 NA  34 24   22
  9   d9 NA  NA 37   NA
  10 d10 NA  NA 44   NA
  </code></pre>
  
  <p>I would like to end up with the dataframe formatted like so with three columns entitles "Day", "Animal" and "Count":</p>
  
  <pre><code>   Day  Animal  Count
  d1  A1  14
  d2  A1  24
  d3  A1  22
  d4  A1  NA
  d5  A1  NA
  d6  A1  NA
  d7  A1  NA
  d8  A1  NA
  d9  A1  NA
  d10 A1  NA
  d1  A2  9
  d2  A2  15
  d3  A2  34
  d4  A2  2
  d5  A2  12
  d6  A2  34
  d7  A2  234
  d8  A2  34
  d9  A2  NA
  d10 A2  NA
  d1  A3  3
  d2  A3  4
  d3  A3  19
  d4  A3  76
  d5  A3  34
  d6  A3  34
  d7  A3  23
  d8  A3  24
  d9  A3  37
  d10 A3  44
  d1  A1  34
  d2  A1  55
  d3  A1  75
  d4  A1  12
  d5  A1  56
  d6  A1  35
  d7  A1  3
  d8  A1  22
  d9  A1  NA
  d10 A1  NA
  </code></pre>
  
  <p>I know that this should be an easy task but I am really struggling to find the solution. Any help with be much appreciated. </p>