mirror of https://git.sr.ht/~hrbrmstr/splashr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
372 B
8 lines
372 B
trunc_string <- function (x, maxlen = 20, justify = "left") {
|
|
toolong <- nzchar(x) > maxlen
|
|
maxwidth <- ifelse(toolong, maxlen - 3, maxlen)
|
|
chopx <- substr(x, 1, maxwidth)
|
|
lenx <- length(x)
|
|
for (i in 1:length(x)) if (toolong[i]) chopx[i] <- paste(chopx[i], "...", sep = "")
|
|
return(formatC(chopx, width = maxlen, flag = ifelse(justify == "left", "-", " ")))
|
|
}
|
|
|