knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
suppressPackageStartupMessages(library(EloSteepness.data))
# suppressPackageStartupMessages(library(kableExtra))
suppressPackageStartupMessages(library(xtable))
library(EloSteepness.data)
# library(kableExtra)
library(xtable)

This document contains the sources and references for the empirical data we used in Extending Bayesian Elo-rating to quantify the steepness of dominance hierarchies (https://doi.org/10.1101/2022.01.28.478016). It was built using EloSteepness.data (version r packageVersion("EloSteepness.data")).

The actual matrices are in:

library(EloSteepness.data)
empirical_matlist
data("empirical_key")
m <- empirical_key
# m <- m[sample(nrow(m), 60), ]
m$species_fixed[is.na(m$species_fixed)] <- ""
m <- m[order(m$datasetname), ]
m$datasetname <- gsub("_", "\\\\_", m$datasetname)

x <- unique(unlist(regmatches(x = m$reference, gregexpr("(@[a-z-]+[0-9]{4}[a-d]{0,1})", text = m$reference))))
cat(paste(paste0("(ref:", gsub(pattern = "^@", "", x), ") ", x), collapse = "\n\n"))

\setlength\LTleft{-0.8in}

\setlength\LTright{-1in}

for (i in 1:nrow(m)) {
  x <- m$reference[i]
  y <- unlist(regmatches(x = x, gregexpr("(@[a-z-]+[0-9]{4}[a-d]{0,1})", text = x)))
  for (k in y) {
    x <- gsub(pattern = k, paste0("(ref:", gsub(pattern = "^@", "", k), ")"), x)
  }
  m$reference[i] <- x
}

m$species_fixed <- paste0("\\textit{", m$species_fixed, "}")

colnames(m) <- gsub("\\_", " ", colnames(m))
colnames(m)[1:2] <- c("data set", "species")
# colnames(m)

d <- c("d", "s", "s", "s", "d", "d", "f", "s")
a <- c("p{1cm}", "p{4cm}", "p{4cm}", "p{4cm}", "p{1cm}", "p{1cm}", "p{1.5cm}", "p{3cm}")
# a <- c("p{1cm}", "p{4cm}", "p{4cm}", "p{4cm}", "p{1cm}", "p{1cm}", "p{1.5cm}", "p{3cm}")
# xtab <- xtable(m[, 1:7],label='tabbidafafg',caption='Example of longtable spanning several pages', display = d, align = a)

xtab <- xtable(m[, 1:7], 
               label = "tab:domnets", 
               caption = "Dominance interaction networks", 
               display = d)
align(xtab) <- c("p{0.1\\textwidth}", 
                 "p{0.23\\textwidth}", 
                 "p{0.19\\textwidth}",
                 "p{0.2\\textwidth}",
                 "p{0.04\\textwidth}",
                 "p{0.08\\textwidth}", 
                 "p{0.08\\textwidth}",
                 "p{0.22\\textwidth}")

addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste(
  "\\hline \n",
  "\\endhead \n",
  "\\hline \n",
  "{\\footnotesize Continued on next page} \n",
  "\\endfoot \n",
  "\\endlastfoot \n",
  sep = ""))

# addtorow <- list(pos = list(0),command = "\\hline \\endhead ")
print(xtab, 
      tabular.environment = "longtable",
      caption.placement = "top", 
      sanitize.text.function = function(x) {x}, 
      booktabs = TRUE,
      floating = FALSE,
      comment = FALSE,
      include.rownames = FALSE, 
      size = "\\footnotesize", #  size="\\fontsize{7pt}{9pt}\\selectfont", 
      hline.after = c(-1, nrow(xtab)),
      add.to.row = addtorow)

References



gobbios/EloSteepness.data documentation built on Oct. 18, 2022, 11:19 p.m.