title: Altering thickness of line graph based on counts
body: <p>Dataframe &quot;id&quot; has the columns year, id, and matriline, where each row is an incident. I wanted to count the number of incidents by matriline per year, so I did:</p>
  <pre><code>events.bymatr = 
  id %&gt;%
  group_by(year, matr, .drop = FALSE) %&gt;%
  dplyr::summarise(n = n()) %&gt;%
  ungroup()
  events.bymatr
  </code></pre>
  <p>I plotted a line graph of the number of incidents over time, by matriline.</p>
  <pre><code>ggplot(events.bymatr, aes(x=year, y=n, group=matr)) + geom_line(aes(color=matr))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Sur2E.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Sur2E.jpg" alt="enter image description here" /></a></p>
  <p>My question is twofold:</p>
  <ol>
  <li><p>Is there a way I could recreate this line graph where the thickness of the lines is determined by how many IDs there were, per matriline? I imagine this would involve reshaping my data above but when I tried to group_by(year,matr,id,.drop=FALSE) my data came out all wonky.</p>
  </li>
  <li><p>I want to change the color palete so that each color is very distinct - how do I attach a new color palette? I tried using <a href="https://stackoverflow.com/questions/9563711/r-color-palettes-for-many-data-classes">this c25 palette</a> with this code but it makes all my lines disappear.
  ggplot(events.bymatr, aes(x=year, y=n, group=matr)) + geom_line(aes(color=c25))</p>
  </li>
  </ol>
  <p>Thanks so much in advance!</p>
  <p>Output of &quot;id&quot; (shortened to just the first five rows per column):</p>
  <pre><code>&gt; dput(id)
      structure(list(date = structure(c(8243, 8243, 8243, 8248, 8947,
      class = &quot;Date&quot;), year = c(1992L, 1992L, 1992L, 1992L, 1994L), 
      event.id = c(8L, 8L, 8L, 10L, 11L), id = structure(c(51L, 55L, 59L, 
      46L, 51L), .Label = c(&quot;J11&quot;, &quot;J16&quot;, &quot;J17&quot;, &quot;J2&quot;, &quot;J22&quot;),
      class = &quot;factor&quot;), sex = structure(c(1L, 2L, 2L, 1L, 1L),
      .Label = c(&quot;0&quot;, &quot;1&quot;), class = &quot;factor&quot;), age = c(28L, 12L, 6L, 42L, 
      30L), matr = structure(c(20L, 20L, 20L, 11L, 20L), .Label = c(&quot;J2&quot;, 
      &quot;J4&quot;, &quot;J7&quot;, &quot;J9&quot;, &quot;K11&quot;), class = &quot;factor&quot;),
      matralive = structure(c(2L, 2L, 2L, 2L, 2L),
      .Label = c(&quot;0&quot;, &quot;1&quot;), class = &quot;factor&quot;), pod = structure(c(3L, 3L, 
      3L, 3L, 3L), .Label = c(&quot;J&quot;, &quot;K&quot;, &quot;L&quot;), class = &quot;factor&quot;)),
      row.names = c(NA, -134L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;))
  </code></pre>
  <p>Output of events.bymatr:</p>
  <pre><code>&gt; dput(events.bymatr)
        structure(list(year = c(1992L, 1992L, 1992L, 1992L, 1992L),
        matr = structure(c(1L, 2L, 3L, 4L, 5L), .Label = c(&quot;J2&quot;, &quot;J4&quot;, 
        &quot;J7&quot;, &quot;J9&quot;, &quot;K11&quot;), class = &quot;factor&quot;), n = c(0L, 0L, 0L, 0L, 0L)), 
        row.names = c(NA, -380L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, 
        &quot;data.frame&quot;))
  </code></pre>