mirror of
https://github.com/msberends/AMR.git
synced 2026-10-01 04:13:33 +02:00
Try to support older R versions
This commit is contained in:
1 parent
a814d82b4b
commit
4b5530ed64
4 files changed
+57
-32
No files matched your search
@@ -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