Skip to content

Commit 740ed2e

Browse files
committed
extract constant
1 parent 5ea75a8 commit 740ed2e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

R/format.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ is_vector_s3.blob <- function(x) TRUE
3434
blob_size <- function(x, digits = 3, trim = TRUE, ...) {
3535
x <- vapply(x, length, numeric(1))
3636

37-
power <- min(floor(log(abs(x), 1000)), 4)
37+
units <- c("kb", "Mb", "Gb", "Tb")
38+
power <- min(floor(log(abs(x), 1000)), length(units))
3839
if (power < 1) {
3940
unit <- "B"
4041
} else {
41-
unit <- c("kb", "Mb", "Gb", "Tb")[[power]]
42+
unit <- units[[power]]
4243
x <- x / (1024 ^ power)
4344
}
4445

0 commit comments

Comments
 (0)