[Bioc-devel] Possible bug in showAsCell,character

Laurent Gatto |@urent@g@tto @end|ng |rom uc|ouv@|n@be
Sun May 5 04:36:36 CEST 2019


Example code to reproduce the bug report:

> DataFrame(a = 'foo', b = NA_character_)
DataFrame with 1 row and 2 columns
Error in if (nchar(x) > n) paste0(paste(strsplit(x, "")[[1]][1:n], collapse = ""),  (from reduce.R#6) : 
  missing value where TRUE/FALSE needed

Suggested patch:

setMethod("showAsCell", "character",
          function (object) {
              n <- 10
              sapply(object, function(x) {
                  if (!is.na(x) & nchar(x) & nchar(x) > n) 
                      paste0(paste(strsplit(x, "")[[1]][1:n], collapse = ""), 
                             "...")
                  else x
              })
          })


With patch:

> DataFrame(a = 'foo', b = NA_character_)
DataFrame with 1 row and 2 columns
               a           b
     <character> <character>
foo        foo          NA


Best wishes,

Laurent



More information about the Bioc-devel mailing list