2

Following the instructions, I came up with the following:

library(papaja)
library(datasets)
library(stats)
library(multcomp)


bla <- glm('MPG.highway ~ DriveTrain*Origin',data = Cars93)
contrast.matrix <- rbind('main' = c(0,1,0,0,0.5,0), 'int' = c(0,0,0,0,1,0))
blac <-  glht(bla, linfct = contrast.matrix)
apa_print.glht(blac,test = multcomp::adjusted())
apa_print.summary.glht(summary(blac,test=adjusted(type="bonferroni")))

that does not work: "Can't subset columns that don't exist. x Column p.value doesn't exist."

Any better ideas? Or since the package is experimental it does not work at all yet? Tips on how to print the output of glht to an htlm document produced by knitr are also accepted.

fabiob
  • 273
  • 4
  • 14

2 Answers2

2

The documentation of apa_print.glht() notes

These methods are not properly tested and should be considered experimental.

It seems that there have been some upstream changes that caused this method to fail. Sorry about that, but it should now be fixed. Please trying installing the latest development version of papaja :

remotes::install_github("crsh/papaja@devel")

apa_print(blac,test = multcomp::adjusted())
crsh
  • 1,699
  • 16
  • 33
  • thanks for this suggestion! I now get a different error message, possibly related to my papaja installation which I am trying to debug (so I liked your answer but cannot accept yet). – fabiob Jul 23 '20 at 10:07
  • What error are you getting? Are you using the latest version of `papaja`? – crsh Jul 24 '20 at 22:08
  • I now have the latest version installed: ```packageVersion('papaja') [1] ‘0.1.0.9997’``` and the error message is the same as before: ```Can't subset columns that don't exist. x Column p.value doesn't exist.``` – fabiob Aug 03 '20 at 11:17
  • 1
    The `emm()` function is not designed to be used that way. It is supposed to be used *within* the glht() call to *generate* a contrast matrix for the linfct argument. If the contrast matrix is already what you want, you shouldn't call emm() st all. – Russ Lenth Aug 03 '20 at 16:56
  • We have now pushed a proper fix to GitHub. – crsh Sep 28 '20 at 10:07
-1

After installing the last devel. version of papaja, and running apa_print with an "emmeans" object, the same error occures in my case as well:

<error/vctrs_error_subscript_oob>

Error: Can't subset columns that don't exist. x Column p.value doesn't exist.

Lukas
  • 11
  • 2