sprintf_max <- function(N = 5000, fmt, ...) {
# Break a character string into chunks and apply the same sprintf() call to each chunk.
# sprintf() has a maximal format length of 8192. Calling sprintf() on a string greater
# than this length will fail. That's where this function comes in!
# Retrieved from:
# https://stackoverflow.com/questions/32862507/r-sprintf-maximal-input-length
#
# Arguments:
# N {numeric} -- character chunk size
# fmt {char} -- string to call sprintf() on
# ... : additional parameters passed into sprintf()
#
# Returns:
# char
cl <- as.list(match.call())
n <- nchar(fmt)
p <- which(unlist(strsplit(fmt,""))=="%")
result <- list()
for ( i in 0:(n%/%N)) {
start <- i*N+1
end <- min((i+1)*N,n)
fm <- substr(fmt,start,end)
k <- which(p %in% (start:end))
v <<- c(list(fm), cl[k+3])
result[[i+1]] <- do.call("sprintf", v )
}
return(result)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.