dcomtois / summarytools

R Package to Quickly and Neatly Summarize Data
523 stars 78 forks source link

dfSummary() fails if data frame has list columns #135

Closed stefanocoretta closed 3 years ago

stefanocoretta commented 3 years ago

R 4.0.3 (2020-10-10). summarytools 0.9.8 tibble 3.0.6 macOS 11.2 (20D64)

dfSummary() fails if the tibble passed to it has list columns.

library(summarytools)
library(tibble)
view(dfSummary(tibble(a = list(c(1, 2)))))
#> Error in withCallingHandlers(expr, warning = function(w) if (inherits(w,  : 
#>  'list' object cannot be coerced to type 'double'
dcomtois commented 3 years ago

Hi, could you provide a bit of context in which those list columns would occur, and what might be a sensible way to deal with that from the stand point of a dfSummary? Thx

stefanocoretta commented 3 years ago

Hello! There are multiple uses for list columns, for example to hold multidimensional data or non-tabular data, vectors of different lengths, data frames and so on.

So there isn't really one general way to deal with list columns.

One simple solution could be to simply print out the type of list if the column is a list column (numeric, character, data frame, etc).

dcomtois commented 3 years ago

Fixed in upcoming version.