title: Is there a clever way to get two column spanner labels in an R GT table?
body: <p>The code below</p>
  <pre><code>library(magrittr)
  library(gt)
  library(dplyr)
  
  TestColumn_one &lt;- c(&quot;CA&quot;, &quot;FL&quot;, &quot;GA&quot;, &quot;MA&quot;, &quot;NM&quot;, &quot;OH&quot;, &quot;OK&quot;, &quot;TN&quot;, &quot;UT&quot;)
  TestColumn_two &lt;- c(1, 2, 3, 4, 5, 6, 7, 8, 9)
  TestColumn_three &lt;- c(1, 2, 3, 4, 5, 6, 7, 8, 9)
  TestColumn_four &lt;- c(1, 2, 3, 4, 5, 6, 7, 8, 9)
  TestColumn_five &lt;- c(1, 2, 3, 4, 5, 6, 7, 8, 9)
  TestColumn_six &lt;- c(&quot;Community 1&quot;,
                      &quot;Community 2&quot;,
                      &quot;Community 3&quot;,
                      &quot;Community 4&quot;,
                      &quot;Community 5&quot;,
                      &quot;Community 6&quot;,
                      &quot;Community 7&quot;,
                      &quot;Community 8&quot;,
                      &quot;Community 9&quot;)
  TestColumn_seven &lt;- c(1, 2, 3, 4, 5, 6, 7, 8, 9)
  
  test.dashboard.data &lt;- data.frame(TestColumn_one, TestColumn_two,TestColumn_three, 
                                    TestColumn_four, TestColumn_five, TestColumn_six,
                                    TestColumn_seven,
                                    stringsAsFactors = FALSE)
  
  names(test.dashboard.data)[1] &lt;- &quot;State&quot;
  names(test.dashboard.data)[2] &lt;- &quot;NCIncidence&quot;
  names(test.dashboard.data)[3] &lt;- &quot;NCRiskLevel&quot;
  names(test.dashboard.data)[4] &lt;- &quot;TestIncidence&quot;
  names(test.dashboard.data)[5] &lt;- &quot;TestRiskLevel&quot;
  names(test.dashboard.data)[6] &lt;- &quot;LocalCommunity&quot;
  names(test.dashboard.data)[7] &lt;- &quot;LocalRisk&quot;
  
  testBoard &lt;- test.dashboard.data %&gt;% gt() %&gt;%
    tab_header(
      title = md(&quot;**CDC Risk Levels**&quot;),
      subtitle = md(&quot;*Based on 14-day moving average of cases per 100,000*&quot;)
    ) %&gt;%
    cols_label(NCIncidence = &quot;Incidence&quot;,
               NCRiskLevel = &quot;Risk Level&quot;,
               TestIncidence = &quot;Incidence&quot;,
               TestRiskLevel = &quot;Risk Level&quot;,
               LocalCommunity = &quot;Local Community&quot;,
               LocalRisk = &quot;Risk Level&quot;) %&gt;%
    
    #These two spanners get clobbered by the last two
    tab_spanner(label=&quot;New Cases&quot;, columns=vars(NCIncidence, NCRiskLevel)) %&gt;%
    tab_spanner(label=&quot;Test Positivity&quot;, columns=vars(TestIncidence, TestRiskLevel)) %&gt;%
    
    
    tab_spanner(label=&quot;Statewide&quot;, columns=vars(NCIncidence, NCRiskLevel, TestIncidence, TestRiskLevel)) %&gt;%
    tab_spanner(label=&quot;Localities&quot;, columns=vars(LocalCommunity, LocalRisk))
  
  
  print(testBoard)
  </code></pre>
  <p>produces this table...the data is obviously junk to hold the place in the columns but you get the idea.</p>
  <p><a href="https://i.stack.imgur.com/4I1lw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4I1lw.png" alt="enter image description here" /></a></p>
  <p>And as you can see the two spanner column labels</p>
  <pre><code>  tab_spanner(label=&quot;New Cases&quot;, columns=vars(NCIncidence, NCRiskLevel)) %&gt;%
    tab_spanner(label=&quot;Test Positivity&quot;, columns=vars(TestIncidence, TestRiskLevel)) %&gt;%
  </code></pre>
  <p>are overwritten.  Is there a way around this to achieve two rows of spanner labels?  Or is that just not possible?</p>
  <p>Stackoverflow says my post is mostly code and I have to add more details so I'm typing more characters down here in hopes of clearing that hurdle...but hopefully the question is clear.</p>