Skip to content

dfSummary does not work when calling it within some functions #205

@Jiefei-Wang

Description

@Jiefei-Wang

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions