TysonStanley / furniture

The furniture R package contains table1 for publication-ready simple and stratified descriptive statistics, tableC for publication-ready correlation matrixes, and other tables #rstats
49 stars 7 forks source link

not getting cross references for tables #20

Closed ericpgreen closed 4 years ago

ericpgreen commented 4 years ago

I'm using the {papaja} package (which builds on {bookdown}'s pdf_document2() to create pdfs from markdown. I can get kable() tables to have cross-references, but not furniture::table1 tables.

---
title             : "The title"
shorttitle        : "Title"

author: 
  - name          : "First Author"
    affiliation   : "1"
    corresponding : yes    # Define only one corresponding author
    address       : "Postal address"
    email         : "my@email.com"
  - name          : "Ernst-August Doelle"
    affiliation   : "1,2"

affiliation:
  - id            : "1"
    institution   : "Wilhelm-Wundt-University"
  - id            : "2"
    institution   : "Konstanz Business School"

authornote: |
  Add complete departmental affiliations for each author here. Each new line herein must be indented, like this line.

  <!-- https://tinyurl.com/ybremelq -->

keywords          : "keywords"
wordcount         : "X"

bibliography      : ["r-references.bib"]

floatsintext      : no
figurelist        : no
tablelist         : no
footnotelist      : no
linenumbers       : yes
mask              : no
draft             : no

documentclass     : "apa6"
classoption       : "man"
output            : papaja::apa6_pdf
header-includes:
  - \raggedbottom
---

```{r setup, include = FALSE}
library("papaja")
library(tidyverse)
library(furniture)

Table \@ref(tab:kable).

  mtcars %>%
  slice(1:4) %>%
  knitr::kable(caption = "My kable table.")

Table \@ref(tab:furniture).

x  <- runif(1000)
y  <- rnorm(1000)
z  <- factor(sample(c(0,1), 1000, replace=TRUE))
a  <- factor(sample(c(1,2), 1000, replace=TRUE))
df <- data.frame(x, y, z, a)

# Simple
# table1(df, x, y, z, a,
#        caption = "My furniture table.",
#        output = "latex2")

# Works if 
table1(df, x, y, z, 
       splitby = "a",
       caption = "My furniture table.",
       output = "latex2")

R version 3.5.0 (2018-04-23) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.14.5

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] qwraps2_0.4.2 furniture_1.9.5 papaja_0.1.0.9842 jtools_2.0.1 kableExtra_1.1.0 [6] reshape2_1.4.3 showtext_0.6 showtextdb_2.0 sysfonts_0.8 forcats_0.3.0
[11] stringr_1.4.0 dplyr_0.8.3 purrr_0.3.2 readr_1.1.1 tidyr_0.8.3.9000 [16] tibble_2.1.3 ggplot2_3.2.0 tidyverse_1.2.1 devtools_1.13.5 RPostgres_1.1.1

loaded via a namespace (and not attached): [1] httr_1.4.0 bit64_0.9-7 jsonlite_1.6 viridisLite_0.3.0 [5] modelr_0.1.2 StanHeaders_2.18.1 assertthat_0.2.1 highr_0.8
[9] stats4_3.5.0 pander_0.6.3 blob_1.1.1 cellranger_1.1.0
[13] yaml_2.2.0 pillar_1.4.2 backports_1.1.4 lattice_0.20-38
[17] glue_1.3.1.9000 digest_0.6.20 rvest_0.3.2 colorspace_1.3-2
[21] htmltools_0.3.6 plyr_1.8.4 pkgconfig_2.0.2 rstan_2.18.2
[25] broom_0.5.2 haven_1.1.2 bookdown_0.13 scales_1.0.0
[29] webshot_0.5.1 processx_3.1.0 git2r_0.26.1 generics_0.0.2
[33] withr_2.1.2 lazyeval_0.2.2 cli_1.1.0 magrittr_1.5
[37] crayon_1.3.4 readxl_1.1.0 memoise_1.1.0 evaluate_0.14
[41] nlme_3.1-137 xml2_1.2.0 pkgbuild_1.0.0 loo_2.0.0
[45] tools_3.5.0 hms_0.4.2 matrixStats_0.54.0 munsell_0.5.0
[49] callr_2.0.4 packrat_0.4.9-3 compiler_3.5.0 rlang_0.4.0
[53] debugme_1.1.0 grid_3.5.0 rstudioapi_0.10 rmarkdown_1.15
[57] gtable_0.3.0 inline_0.3.15 DBI_1.0.0 curl_3.3
[61] R6_2.4.0 gridExtra_2.3 lubridate_1.7.4 knitr_1.26
[65] bit_1.1-14 zeallot_0.1.0 stringi_1.4.3 parallel_3.5.0
[69] Rcpp_1.0.2 vctrs_0.2.0 tidyselect_0.2.5 xfun_0.11

TysonStanley commented 4 years ago

Did you try the label argument in table1()?

For example:

Table \@ref(tab:furniture).

```{r furniture, results="asis"}
x  <- runif(1000)
y  <- rnorm(1000)
z  <- factor(sample(c(0,1), 1000, replace=TRUE))
a  <- factor(sample(c(1,2), 1000, replace=TRUE))
df <- data.frame(x, y, z, a)

table1(df, x, y, z, 
       splitby = "a",
       caption = "My furniture table.",
       output = "latex2",
       label = "tab:furniture")
ericpgreen commented 4 years ago

Thanks! I tried without “tab:” and concluded label did not work.

On Dec 10, 2019, at 4:46 PM, Tyson Barrett notifications@github.com wrote:

 Did you try the label argument in table1()?

For example:

Table \@ref(tab:furniture).


x  <- runif(1000)
y  <- rnorm(1000)
z  <- factor(sample(c(0,1), 1000, replace=TRUE))
a  <- factor(sample(c(1,2), 1000, replace=TRUE))
df <- data.frame(x, y, z, a)

table1(df, x, y, z, 
       splitby = "a",
       caption = "My furniture table.",
       output = "latex2",
       label = "tab:furniture")
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.