title: Set the alignment of columns based on their data type using gt package
body: <p>Given a data sample and gt code to plot table below:</p>
  <pre><code>df &lt;- structure(list(category = c(&quot;food&quot;, &quot;food&quot;, &quot;food&quot;, &quot;food&quot;, &quot;electronic product&quot;, 
  &quot;electronic product&quot;, &quot;electronic product&quot;, &quot;electronic product&quot;
  ), type = c(&quot;vegetable&quot;, &quot;vegetable&quot;, &quot;fruit&quot;, &quot;fruit&quot;, &quot;computer&quot;, 
  &quot;computer&quot;, &quot;other&quot;, &quot;other&quot;), variable = c(&quot;cabbage&quot;, &quot;radish&quot;, 
  &quot;apple&quot;, &quot;pear&quot;, &quot;monitor&quot;, &quot;mouse&quot;, &quot;camera&quot;, &quot;calculator&quot;), 
      price = c(6, 5, 3, 2.9, 2000, 10, 600, 35), quantity = c(2L, 
      4L, 5L, 10L, 1L, 3L, NA, 1L)), class = &quot;data.frame&quot;, row.names = c(NA, 
  -8L))
  </code></pre>
  <p>To plot:</p>
  <pre><code>dt &lt;- df %&gt;% 
    group_by(category) %&gt;%
    gt() %&gt;% 
    tab_header(
      title = md(&quot;Category name&quot;)
    )%&gt;%
       tab_style(
       locations = cells_column_labels(columns = everything()),
       style     = list(
         #Give a thick border below
         cell_borders(sides = &quot;bottom&quot;, weight = px(3)),
         #Make text bold
         cell_text(weight = &quot;bold&quot;)
       )
     ) %&gt;%
       tab_style(
       locations = cells_row_groups(groups = everything()),
       style     = list(
         cell_text(weight = &quot;bold&quot;)
       )
     ) %&gt;%
    cols_align(align = &quot;center&quot;, columns = everything())
  dt
  </code></pre>
  <p>Out:</p>
  <p><a href="https://i.stack.imgur.com/crxT6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/crxT6.png" alt="enter image description here" /></a></p>
  <p>Now I hope to custom <code>cols_align()</code> to align columns <code>type</code>, <code>variable</code>, <code>price</code> and <code>quantity</code> based on their datatype, if the datatype is character using <code>center</code>, if is number then using <code>left</code>.</p>
  <p>How could I modify the code achieve that? Thanks.</p>