Use seq_along instead of 1:length(x)

It behaves when length(x) == 0
This commit is contained in:
Joe Cheng
2018-03-27 18:30:03 -07:00
parent e5d1c61cdf
commit 2ef7226be0
2 changed files with 2 additions and 2 deletions

View File

@@ -588,7 +588,7 @@ flexfill <- function(..., direction, flex, width = width, height = height) {
}
if (length(flex) > length(children)) {
flex <- flex[1:length(children)]
flex <- flex[seq_along(children)]
}
# The dimension along the main axis

View File

@@ -321,7 +321,7 @@ printStackTrace <- function(cond,
SIMPLIFY = FALSE
)
dfs <- mapply(1:length(stackTraceCalls), rev(stackTraceCalls), rev(stackTraceCallNames), rev(toShow), FUN = function(i, calls, nms, index) {
dfs <- mapply(seq_along(stackTraceCalls), rev(stackTraceCalls), rev(stackTraceCallNames), rev(toShow), FUN = function(i, calls, nms, index) {
st <- data.frame(
num = rev(which(index)),
call = rev(nms[index]),