dcomtois/summarytools

Bug in print generic implementation for list

struckma opened this issue · 1 comments

Dear maintainers, thank you for this great and versatile package. Unfortunately, I have to inform you about a bug in summarytools , where you have an implementation for the print generic for list objects. You assume, that all printed lists always have elements. Code to reproduce:

> # a fresh, unused R session...
> print(list()) # this works as expected
list()
> library(summarytools) # loading summarytools
> print(list()) # retry the formerly working print of an empty list
Error in x[[1]] : subscript out of bounds
> packageVersion("summarytools")
[1] ‘1.0.1

The bug fix would be to change the function print.list, the line:

if (inherits(x[[1]], "summarytools")) {

should become

if (length(x) > 0 && inherits(x[[1]], "summarytools")) {

Thank you for considering a fix, have a great time

Stephan

Thanks Stephan, will be fixed soon.