dstanley4 / apaTables

Development version of apaTables R package. Current stable version is on the CRAN.
http://dstanley4.github.io/apaTables/
Other
55 stars 13 forks source link

apa.reg.table with blocks of continuous and categorical predictors #24

Open niklasjohannes opened 4 years ago

niklasjohannes commented 4 years ago

Thanks a ton for the great package. I was wondering whether it's possible to enter a block with continuous predictors and a block with categorical predictors into apa.reg.table.

Example:

library(tidyverse)
library(apaTables)

dat <-
  tibble(
    dv = rnorm(10, 0, 1),
    iv = rnorm(10, 0, 1),
    cat = rep(c("A", "B"), each = 5)
  )

block1 <- lm(dv ~ iv, data = dat)
block2 <- lm(dv ~ iv + cat, data = dat)

apa.reg.table(block1, block2, filename = "table.doc")

This results in an error message because block2 is a list that itself contains a list with the contrasts for cat. block1 does not have those contrasts, resulting in different numbers of list elements:

Error in rbind(deparse.level, ...) : 
  numbers of columns of arguments do not match

Any way to make this work other than creating numeric 0/1 variables for each dummy contrast?