0

In a Quarto document being prepared for html output, I want to use the Hmisc::describe() function with the html() function, thus:

html(describe(diffs$gama_diff))

I get the following error: Error in FUN(X[[i]], ...) : argument is not a character vector

gama_gt is a numeric vector, but I think the error refers to the output of the describe() function.

I am in a Windows 11 environment in RStudio with R4.2.0. The YAML uses format: html: and a number of sub-arguments.

I'm sure the error is mine, but I'm not sure what it is that I've done.

Jim Hunter
  • 47
  • 1
  • 4
  • The error message is self explanatory. What is `class(describe(diffs$gama_diff))` ? – Ronak Shah Jul 04 '22 at 13:23
  • 1
    Make sure you're using the correct version: there's also `testthat::describe` and `terra::describe`, both expect strings. If you change your `html(describe(...))` to `html(Hmisc::describe(...))`, does the problem resolve? – r2evans Jul 04 '22 at 13:26
  • FYI, your code references `diffs$gama_diff` but you say that `gama_gt` is a numeric vector. I don't know if you're referring to the column of a frame or a standalone, but the code and your statement are not the same. – r2evans Jul 04 '22 at 13:28
  • 2
    Finally, it would help to make this question reproducible, please see https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. Thanks! – r2evans Jul 04 '22 at 13:55
  • Thank you r2evans. Your comments put me in the right direction. Here is a reproducible version of the error using iris: `library(Hmisc)` `library(gt)` `describe(iris$Sepal.Length)` `html(describe(iris$Sepal.Length))` The conflict was with the `gt` package, which also has an `html()` function. Changing the last line of the example to `Hmisc::html(describe(iris$Sepal.Length))` fixes the problem. Fair warning to users of the new `gt` table building program. – Jim Hunter Jul 05 '22 at 10:52

0 Answers0