summarytools icon indicating copy to clipboard operation
summarytools copied to clipboard

dfSummary does not work when calling it within some functions

Open Jiefei-Wang opened this issue 9 months ago • 1 comments

I want to call dfSummary within my function. However, it will give me the following error when I turn the rmd file into HTML:

Error in `if (done) ...`:
! argument is not interpretable as logical
Backtrace:
    ▆
 1. └─summarytools::dfSummary(df)
 2.   └─summarytools:::parse_call(...)
 3.     └─summarytools:::deduce_names()

However, this issue only exists when I knit the whole file, I cannot trigger it within my terminal. The issue seems related to how dfSummary parses R's call stack, as the error only exists for some specific functions. Here is a simple reprex

## install/load packages
library(summarytools)

dfSummaryEX <- function(df) {
    df|> dfSummary() |> print(method = 'render')
}

summaryEX <- function(df) {
    df|> dfSummary() |> print(method = 'render')
}

This will give you the error

dfSummaryEX(data.frame(x=1:10))

This, though literally does the same thing, will not give you error

summaryEX(data.frame(x=1:10))

I do not know the exact implementation for this, but I guess you might use a regular expression to match the call name?

Jiefei-Wang avatar May 10 '25 17:05 Jiefei-Wang

Can you try with this version and let me know pls? Thx remotes::install_version("summarytools", version = "1.1.3", repos = "http://cran.us.r-project.org")

dcomtois avatar Jun 12 '25 03:06 dcomtois