title: Create a tibble with tribble using defaults that don't cause an error, e.g. like tibble
body: <p>A recent update of packages means that this code for neatly making a tibble with <code>tribble()</code> (then used to make a table) no longer works.</p>
  
  <pre><code>library(dplyr)
  table_data_1 &lt;- tribble(~"Header1_A", ~"Header2_A",
                        0.19,          0.20,
                        "Header1_B",  "Header2_B",
                        0.19,          0.20)
  </code></pre>
  
  <p>The error message:</p>
  
  <pre><code>Error: Can't combine `Header1_1` &lt;double&gt; and `Header1_1` &lt;character&gt;.
  Run `rlang::last_error()` to see where the error occurred.
  </code></pre>
  
  <p>And <code>rlang::last_error()</code> produces:</p>
  
  <pre><code>&lt;error/vctrs_error_incompatible_type&gt;
  Can't combine `Header1_A` &lt;double&gt; and `Header1_A` &lt;character&gt;.
  Backtrace:
   1. tibble::tribble(...)
   6. vctrs::vec_default_ptype2(...)
   7. vctrs::stop_incompatible_type(...)
   8. vctrs:::stop_incompatible(...)
   9. vctrs:::stop_vctrs(...)
  Run `rlang::last_trace()` to see the full context.
  </code></pre>
  
  <p>Now that is probably one interpretation of reasonable that a recent update would make a default class for a column based on the first row of data, which in this case is then <em>numeric</em>. Then it is totally logical  that it throws an error when I give it some text in the next row, which would be interpreted as <em>character</em> when it expects <em>numeric</em>. However, I'll note that <code>tibble()</code> has more sensible defaults (in my view), so I can create the desired tibble with a sensible default to <em>character</em>.</p>
  
  <pre><code>table_data_2 &lt;- tibble(Header1_A = c(0.19, "Header1_B", 0.19), Header2_A = c(0.19, "Header2_B", 0.19))
  table_data_2
  </code></pre>
  
  <pre><code># A tibble: 3 x 2
    Header1_A Header2_A
    &lt;chr&gt;     &lt;chr&gt;    
  1 0.19      0.19     
  2 Header1_B Header2_B
  3 0.19      0.19  
  </code></pre>
  
  <p>However, it's not clear to me how I could retain the neat data entry of a tribble and override the default behaviour and specify that the columns should all be treated as character, without putting all the numbers in inverted commas - which would not give an identical tibble. </p>
  
  <p><strong>How can I get the tibble default behaviour (a sensible guess of class) with tribble, or specify the class?</strong> </p>
  
  <p><strong>EDIT</strong>
  Someone asked what my use case was. Basically I just wanted a neat tribble/tibble to demonstrate how you might go about making a table in rmarkdown that was a downloadable table in html output (with <strong>DT</strong>), or just neatly formatted in pdf/latex output with <strong>kableExtra</strong>). I live in hope that <strong>gt</strong> makes a lot of this stuff unnecessary!</p>
  
  <pre><code>---
  title: "Untitled"
  author: "me"
  date: "22/05/2020"
  output:
    # pdf_document:
    #   latex_engine: xelatex
    html_document: default
  ---
  
  ```{r setup, echo=FALSE, message=FALSE}
  library(tidyverse)
  table_data_2 &lt;- tibble(Header1_A = c(0.19, "Header1_B", 0.19), Header2_A = c(0.19, "Header2_B", 0.19))
  table_data_2
  
  
  ## Format table packages
  library(kableExtra)
  library(DT)
  
  ## Format for latex/PDF
  my_table &lt;- kable(table_data_2, format="latex", caption = "Dairy Farm Owner-operator Terms of Trade") %&gt;%
    kable_styling(latex_options = c("striped", "hold_position")) %&gt;%
    row_spec(c(0,2), bold = T) %&gt;% 
    row_spec(0:(table_data_2 %&gt;% 
                  nrow()), extra_latex_after = "\\arrayrulecolor{gray}") %&gt;% 
    row_spec(seq(1,table_data_2 %&gt;% 
                   nrow(),2), background = "#daf7e1")
  
  my_table #if latex output
  
  ## Format for html
  
  #formatting the row stripes for datatables tables
  callback &lt;- c(
    "$('table.dataTable.display tbody tr:odd').css('background-color', '#b3ffd9');",
    "$('table.dataTable.display tbody tr:even').css('background-color', 'white');",
    "$('table.dataTable.display tbody tr:odd')",
    "  .hover(function(){",
    "    $(this).css('background-color', '#74e3ab');",
    "   }, function(){",
    "    $(this).css('background-color', '#b3ffd9');",
    "   }",
    "  );",
    "$('table.dataTable.display tbody tr:even')",
    "  .hover(function(){",
    "    $(this).css('background-color', '#d4d4d4');",
    "   }, function(){",
    "    $(this).css('background-color', 'white');",
    "   }",
    "  );"
  )
  
  formatStyle(
    datatable(table_data_2, extensions = 'Buttons',
              options=list(dom = 'Brt', buttons = c('excel','csv','print'),
                           pageLength=dim(table_data_2)[1],
                           ordering = FALSE),
              rownames = FALSE, 
              callback = JS(callback)
    ), 1, target = "row",
    fontWeight = styleEqual("Header1_B", "bold") )
  
  
  ```
  </code></pre>
  
  <p>For what its worth, image shows html on left, pdf/latex on right.</p>
  
  <p><a href="https://i.stack.imgur.com/KTn8s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KTn8s.png" alt="output"></a></p>