Skip to content

Commit

Permalink
Sacrifice at the altar of all-mighty lintr!
Browse files Browse the repository at this point in the history
  • Loading branch information
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q committed May 28, 2024
1 parent 03652da commit 52c66fc
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions R/mbind.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,46 +76,46 @@ mbind <- function(...) { #nolint
" data objects! Cannot handle this case!")
}

diffall <- c('spatial' = diffspat, 'temporal' = difftemp, 'data' = diffdata)
diffall <- c("spatial" = diffspat, "temporal" = difftemp, "data" = diffdata)
if (1 < sum(diffall)) {
msg <- c("Cannot handle objects!",
paste(
paste(head(names(diffall)[diffall], n = -1),
collapse = ", "),
tail(names(diffall)[diffall], n = 1),
sep = " as well as "),
paste(paste(head(names(diffall)[diffall], n = -1),
collapse = ", "),
tail(names(diffall)[diffall], n = 1),
sep = " as well as "),
"dimensions differ!")
substr(msg[2], 1, 1) <- toupper(substr(msg[2], 1, 1))

msg <- paste(
c(paste(msg, collapse = " "),
" Differences from first mbind() input:",
vapply(which(diffall), function(i) {
msg <- paste(c(paste(msg, collapse = " "),
" Differences from first mbind() input:",
vapply(which(diffall), function(i) {

lhs <- getItems(inputs[[1]], dim = i)
rhs <- Reduce(union, lapply(tail(inputs, n = -1), getItems, dim = i))
lhs <- getItems(inputs[[1]], dim = i)
rhs <- Reduce(union, lapply(tail(inputs, n = -1),
getItems, dim = i))

# do a kind of three-way diff
diff <- list('missing' = setdiff(lhs, rhs),
' having' = intersect(lhs, rhs),
' adding' = setdiff(rhs, lhs))
# do a kind of three-way diff
diff <- list("missing" = setdiff(lhs, rhs),
" having" = intersect(lhs, rhs),
" adding" = setdiff(rhs, lhs))

diff <- lapply(diff, function(x) {
if (4 < length(x)) { # shorten to four elements, like str() does
x <- c(paste0("`", x[1:4], "`"), "...")
} else if (0 < length(x)) {
x <- paste0("`", x, "`")
}
return(paste(x, collapse = ", "))
})
diff <- lapply(diff, function(x) {
if (4 < length(x)) {
# shorten to four elements, like str() does
x <- c(paste0("`", x[1:4], "`"), "...")
} else if (0 < length(x)) {
x <- paste0("`", x, "`")
}
return(paste(x, collapse = ", "))
})

# paste diff
d <- nzchar(diff)
paste(c(paste0(" ", names(diffall)[i], ":"),
paste(paste0(" ", names(diff)[d], ":"), diff[d])),
collapse = "\n")
}, character(1))),
collapse = "\n")
# paste diff
d <- nzchar(diff)
paste(c(paste0(" ", names(diffall)[i], ":"),
paste(paste0(" ", names(diff)[d], ":"),
diff[d])),
collapse = "\n")
}, character(1))), collapse = "\n")
stop(msg)
}

Expand Down

0 comments on commit 52c66fc

Please sign in to comment.