title: ddply - common mistake when error "'names' attribute [] must be the same length as the vector []" occurs?
body: <p>I know that there is a few threads (<a href="https://stackoverflow.com/questions/18854934/ddply-error-error-in-attributesout-attributescol-names-attribute-mus">1</a>, <a href="https://stackoverflow.com/questions/14153092/meaning-of-ddply-error-names-attribute-9-must-be-the-same-length-as-the-vec">2</a>) already about it and I have read them, but I still do not find my problem.</p>
  
  <p>The error seems to occur "randomly", even though I am sure it is not, but I can just not figure out, when. </p>
  
  <p>Therefore I cannot really provide a minimal example, as I could not find a "pattern" yet.</p>
  
  <p>But basically I always use</p>
  
  <pre><code>hourly &lt;- ddply(set, c("Date", "Hour"), summarise, avg = mean(Value))
  </code></pre>
  
  <p>which leads to</p>
  
  <pre><code>Error: 'names' attribute [11] must be the same length as the vector [1]
  </code></pre>
  
  <p>traceback() provides</p>
  
  <pre><code>&gt; traceback()
  6: stop(list(message = "Attribut 'names' [11] muss dieselbe Länge haben wie der Vektor [1]", 
         call = NULL, cppstack = NULL))
  5: .Call("plyr_loop_apply", PACKAGE = "plyr", n, f)
  4: loop_apply(n, do.ply)
  3: llply(.data = .data, .fun = .fun, ..., .progress = .progress, 
         .inform = .inform, .parallel = .parallel, .paropts = .paropts)
  2: ldply(.data = pieces, .fun = .fun, ..., .progress = .progress, 
         .inform = .inform, .parallel = .parallel, .paropts = .paropts)
  1: ddply(set, c("Date", "Hour"), summarise, avg = mean(Value))
  </code></pre>
  
  <p>The str() of the dataframe:</p>
  
  <pre><code>&gt; str(set)
  'data.frame':   2155 obs. of  16 variables:
   $ T_Stamp : POSIXlt, format: "2013-06-18 09:01:00" "2013-06-18 09:02:00" "2013-06-18 09:03:00" ...
   $ Date    : Date, format: "2013-06-18" "2013-06-18" "2013-06-18" ...
   $ Time    : num  0.376 0.376 0.377 0.378 0.378 ...
   $ Year    : int  2013 2013 2013 2013 2013 2013 2013 2013 2013 2013 ...
   $ Month   : int  6 6 6 6 6 6 6 6 6 6 ...
   $ Day     : int  18 18 18 18 18 18 18 18 18 18 ...
   $ Hour    : int  9 9 9 9 9 9 9 9 9 9 ...
   $ Min     : int  1 2 3 4 5 6 7 8 9 10 ...
   $ Customer: chr  "1" "1" "1" "1" ...
   $ Property: chr  "1" "1" "1" "1" ...
   $ Serial  : Factor w/ 13 levels "000D6F00010B723F",..: 9 9 9 9 9 9 9 9 9 9 ...
   $ Sensor  : chr  "AirCon" "AirCon" "AirCon" "AirCon" ...
   $ ID      : Factor w/ 44 levels "300","301","302",..: 30 30 30 30 30 30 30 30 30 30 ...
   $ Unit    : chr  "Total Active Power" "Total Active Power" "Total Active Power" "Total Active   Power" ...
   $ Value   : num  68 68.2 68.2 67.7 68.5 ...
   $ Hourf   : Factor w/ 13 levels "9","10","11",..: 1 1 1 1 1 1 1 1 1 1 ...
  </code></pre>
  
  <p>Does anyone know about a common mistake one can do, when using ddply for summarising (as I do for calculating means)?</p>