title: combining sparkline in kableExtra table
body: <p>I am trying to create a table with subheadings and sparklines.</p>
  
  <p>I am able to create the table with subheading with the <code>kableExtra</code> package. And I am able to create a table with sparklines with the <code>formattable</code> and <code>sparkline</code> package.</p>
  
  <p>However, I am not able to combine both. Is there way?
  I saw <a href="https://haozhu233.github.io/kableExtra/use_kableExtra_with_formattable.html" rel="nofollow noreferrer">this</a>, but didn't help me.</p>
  
  <pre><code>library(sparkline)
  library(tidyverse)
  library(formattable)
  library(kableExtra)
  
  df &lt;- data.frame(stringsAsFactors=FALSE,
            V1 = c("country", "A", "B", "C"),
            V2 = c(2000L, 100L, 600L, 50L),
            V3 = c(2001L, 200L, 500L, 60L),
            V4 = c(2002L, 300L, 400L, 70L),
            V5 = c(2003L, 400L, 300L, 80L),
            V6 = c(2004L, 500L, 200L, 90L),
            V7 = c(2005L, 600L, 100L, 100L)
  )
  
  df.names &lt;- df[1,]
  names(df) &lt;- df.names
  df &lt;- df[-1,]
  
  graph &lt;- df %&gt;% 
    group_by(country) %&gt;% 
    gather(key=year, value=value, -country) %&gt;% 
    summarise(graph=spk_chr(
      value, 
      chartRangeMin = 0,
      type="line"))
  
  df2 &lt;- left_join(df, graph, by=c("country"))
  
  
  df2 %&gt;%
    formattable::formattable(align=c("l")) %&gt;% 
    as.htmlwidget() %&gt;% 
    spk_add_deps()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5q5lD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5q5lD.png" alt="enter image description here"></a></p>
  
  <pre><code>df2 %&gt;%
    kable("html", caption="Title", escape=T) %&gt;% 
    kable_styling("striped", full_width = F) %&gt;%
    group_rows("group1", 1, 2) %&gt;%
    group_rows("group2", 3,3)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/hwQcJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hwQcJ.png" alt="enter image description here"></a></p>
  
  <pre><code>df2 %&gt;%
    kable("html", caption="Title", escape=T) %&gt;% 
    kable_styling("striped", full_width = F) %&gt;%
    group_rows("group1", 1, 2) %&gt;%
    group_rows("group2", 3,3) %&gt;% 
    formattable::formattable(align=c("l")) %&gt;% 
    as.htmlwidget() %&gt;% 
    spk_add_deps()
  </code></pre>
  
  <p>Creates error:</p>
  
  <pre><code>Error in create_obj(x, "formattable", list(formatter = formatter, format = list(...),  : 
    argument "formatter" is missing, with no default
  </code></pre>
  
  <p>Note that I tried both <code>kable("html", caption="Title", escape=TRUE) and escape=FALSE</code></p>