Closed isaactpetersen closed 2 years ago
R is calling the wrong print method (Hmisc:::print.describe
which is internal). You really want to use print.psych
, and can change the line to print(psych::describe(df))
. I'm not familiar with psych and its print method but it doesn't look like its output will look nice in "paged" format as it is not a data.frame.
I'm trying to use the
describe()
function from thepsych
package. However, I receive an error when using it after having loaded theHmisc
package, even if specifyingpsych::describe()
:I get the error when rendering an
rmarkdown
(.Rmd
) file. I do not get the error when running the underlying R code. I still get the error even after unloadingHmisc
. I've isolated the issue to when I am specifyingdf_print: paged
in theYAML
settings forhtml_document
.Here is a reproducible example with session info etc. (the error occurs in Section 9): https://isaactpetersen.github.io/reprex/
I understand that this may not be an issue with the
Hmisc
package per se, bur rather the interaction ofHmisc
andpsych
. Nevertheless, it is well documented thatHmisc
andpsych
have key conflicts:https://stackoverflow.com/questions/28986140/psych-and-hmisc-packages-with-describe-class
https://github.com/harrelfe/rms/issues/100
https://github.com/strengejacke/sjPlot/issues/229
One potential solution to this is for the user to not load the
Hmisc
package at all (and to not load any packages that depend onHmisc
), at least not loading them before using anypsych
functions. However, that is not an appealing solution. I hope there is a workable solution that allows loading both packages in whatever order, but specifying which function is intended (and respecting the specified one). I'd like to be able to continue to load and useHmisc
, if possible.Here is the reproducible example (
index.Rmd
):Methods
Load Libraries
Simulate Data
Session Info
Hmisc
is loaded:Methods
Unload
Hmisc
Session Info
Hmisc
is unloaded:Methods
Use
psych::describe()
Throws error:
Session Info
rmarkdown::render("index.Rmd")