mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 09:11:51 +02:00
Try to support older R versions
This commit is contained in:
14
R/misc.R
14
R/misc.R
@ -112,11 +112,23 @@ size_humanreadable <- function(bytes, decimals = 1) {
|
||||
out
|
||||
}
|
||||
|
||||
|
||||
# Support for older R versions --------------------------------------------
|
||||
|
||||
# strrep is only available in R 3.3 and later
|
||||
# and we want to support R 3.2 too, so:
|
||||
strrep <- function(x, times) {
|
||||
for (i in 1:length(x)) {
|
||||
x[i] <- paste(rep(x[i], times[i]), collapse = "")
|
||||
}
|
||||
x
|
||||
}
|
||||
# trimws is only available in R 3.2 and later
|
||||
trimws <- function(x, which = "both") {
|
||||
if (which %in% c("left", "both", "l", "b")) {
|
||||
x <- gsub('^ {1,255}', '', x)
|
||||
}
|
||||
if (which %in% c("right", "both", "r", "b")) {
|
||||
x <- gsub(' {1,255}$', '', x)
|
||||
}
|
||||
x
|
||||
}
|
||||
|
Reference in New Issue
Block a user