Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: print.summarytools fails printing when method="pander" #172

Closed
iagogv3 opened this issue Oct 28, 2022 · 0 comments · Fixed by #173
Closed

Bug: print.summarytools fails printing when method="pander" #172

iagogv3 opened this issue Oct 28, 2022 · 0 comments · Fixed by #173

Comments

@iagogv3
Copy link
Contributor

iagogv3 commented Oct 28, 2022

Minimal reprex

data("tobacco")
summarytools:::print.summarytools(ctable(tobacco$gender, tobacco$smoker))
Error in sys.calls()[[sys.nframe() - 1]] : 
  attempt to select less than one element in get1index <real>

This is due to

# Display message if list object is being printed (console) with base print()
# (thus not taking advantage of print.summarytools() which makes results
# much cleaner in the console)
if (method == "pander" &&
(identical(deparse(sys.calls()[[sys.nframe() - 1]][2]), "x[[i]]()") ||
any(grepl(pattern = "fn_call = FUN(x = X[[i]]",
x = deparse(sys.calls()[[sys.nframe() - 1]]), fixed = TRUE)))) {
message("For best results printing list objects with summarytools, ",
"use print(x); if by() was used, use stby() instead")
}

since sys.nframe() is 1 instead of 2 or greater.

@iagogv3 iagogv3 changed the title Bug: print.summarytools fails printing Bug: print.summarytools fails printing when method="pander" Oct 28, 2022
iagogv3 added a commit to iago-ContributedForks/summarytools that referenced this issue Oct 28, 2022
@iagogv3 iagogv3 mentioned this issue Oct 29, 2022
dcomtois pushed a commit that referenced this issue Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant