Skip to content

Commit

Permalink
fix: invalid value 0 for 'digits' argument
Browse files Browse the repository at this point in the history
fixes  #163
  • Loading branch information
mcanouil authored and dcomtois committed Sep 13, 2022
1 parent 7df2bef commit ba099c2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions R/print.summarytools.R
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ print.summarytools <- function(x,
}

if (!"digits" %in% names(format_info)) {
format_info$digits <- format_info$round.digits
format_info$digits <- max(c(1, format_info$round.digits))
}

# Put modified attributes back into x
Expand Down Expand Up @@ -934,13 +934,13 @@ print_ctable <- function(x, method) {

if (rownames_are_int) {
format_args_tmp <- format_args
format_args_tmp$digits <- 0
format_args_tmp$digits <- 1
format_args_tmp$nsmall <- 0
} else {
# Make sure no decimals are lost b/c of format options
format_args_tmp <- format_args
format_args_tmp$digits <- max(
nchar(sub(".+\\.(.*)0*", "\\1", temp_rownames)),
c(1, nchar(sub(".+\\.(.*)0*", "\\1", temp_rownames))),
na.rm = TRUE
)
format_args_tmp$nsmall <- format_args_tmp$digits
Expand Down Expand Up @@ -970,12 +970,12 @@ print_ctable <- function(x, method) {

if (colnames_are_int) {
format_args_tmp <- format_args
format_args_tmp$digits <- 0
format_args_tmp$digits <- 1
format_args_tmp$nsmall <- 0
} else {
format_args_tmp <- format_args
format_args_tmp$digits <- max(
nchar(sub(".+\\.(.*)0*", "\\1", temp_rownames)),
c(1, nchar(sub(".+\\.(.*)0*", "\\1", temp_rownames))),
na.rm = TRUE
)
format_args_tmp$nsmall <- format_args_tmp$digits
Expand Down Expand Up @@ -2459,4 +2459,3 @@ build_heading_html <- function(format_info, data_info, method, div_id = NA) {
tmp <- list(head1, head2, head3)
return(tmp[which(!is.na(tmp))])
}

0 comments on commit ba099c2

Please sign in to comment.