title: group by sum in ggplot (R)
body: <p>I'm trying to get a plot like this:</p>
  
  <p><a href="https://i.stack.imgur.com/McTAE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/McTAE.jpg" alt="enter image description here"></a>
  I want to get a plot where in each hour interval (hora) plots the sum of nticket for each day (diaSem).</p>
  
  <p>I use this command:</p>
  
  <pre><code>ggplot(PorFranjasHyDIas) + geom_line(aes(hora, sum(nTicket), group=hora, color=diaSem)) 
  </code></pre>
  
  <p>But I get a blank plot.</p>
  
  <p>I got plot from below by switching the main dataset in days, but I couldn't change line thickness and legend title:</p>
  
  <pre><code>ggplot() + 
     geom_line(data = Lunes, aes(x = HORA, y = nTickets, group=1, color="red")) +  
     geom_line(data = Martes, aes(x = HORA, y = nTickets, group=1, color="blue"))  + 
     geom_line(data = Miercoles, aes(x = HORA, y = nTickets, group=1, color="green")) +  
     geom_line(data = Jueves, aes(x = HORA, y = nTickets, group=1, color="yellow")) + 
     geom_line(data = Viernes, aes(x = HORA, y = nTickets, group=1, color="orange")) + 
     geom_line(data = Sabado, aes(x = HORA, y = nTickets, group=1, color="gold2")) +  
     xlab('Franja horaria') +  ylab('Num Tickets')
  </code></pre>
  
  <p><strong>Dataset extract:</strong></p>
  
  <pre><code>diaSem  nTicket esperaMedia hora
  J   148 503,59  08:30-9:00
  J   589 145,5   09:00-09:30
  J   621 124,38  09:30-10:00
  J   665 104,96  10:00-10:30
  J   624 201,79  10:30-11:00
  J   749 248,81  11:00-11:30
  J   795 334,07  11:30-12:00
  J   812 231,75  12:00-12:30
  J   746 183,98  12:30-13:00
  J   679 178,06  13:00-13:30
  J   424 177,82  13:30-14:00
  J   188 583,68  14:00-14:30
  J   72  339 14:30-15:00
  J   41  815 15:00-15:30
  J   45  143,11  15:30-16:00
  J   60  310,32  16:00-16:30
  J   94  182,48  16:30-17:00
  J   165 171,48  17:00-17:30
  J   191 263,28  17:30-18:00
  J   226 324,7   18:00-18:30
  J   165 211,94  18:30-19:00
  L   155 539,19  08:30-9:00
  L   792 279,39  09:00-09:30
  L   694 159,01  09:30-10:00
  L   803 141,48  10:00-10:30
  L   757 364,21  10:30-11:00
  L   875 440,1   11:00-11:30
  L   824 500,16  11:30-12:00
  L   898 277 12:00-12:30
  L   797 264,22  12:30-13:00
  L   710 204,12  13:00-13:30
  L   460 187,62  13:30-14:00
  L   162 333,93  14:00-14:30
  L   52  242,96  14:30-15:00
  L   64  376,17  15:00-15:30
  L   55  65,58   15:30-16:00
  L   80  290,25  16:00-16:30
  L   90  129,59  16:30-17:00
  L   186 229,25  17:00-17:30
  L   251 300,66  17:30-18:00
  L   293 273,04  18:00-18:30
  L   246 174,88  18:30-19:00
  M   204 989,21  08:30-9:00
  M   705 353,57  09:00-09:30
  M   631 255,85  09:30-10:00
  M   698 114,52  10:00-10:30
  M   713 218,98  10:30-11:00
  </code></pre>