[R] many minor changes to increase the robustness of the R code (#2404)

* many minor changes to increase robustness of R code

* fixing which mistake in xgb.model.dt.tree.R and a few cosmetics
This commit is contained in:
Bernie Gray
2017-06-15 23:56:23 -04:00
committed by Vadim Khotilovich
parent 0db37c05bd
commit cd7659937b
8 changed files with 23 additions and 23 deletions

View File

@@ -251,7 +251,7 @@ xgb.train <- function(params = list(), data, nrounds, watchlist = list(),
stop("second argument dtrain must be xgb.DMatrix")
if (length(watchlist) > 0) {
if (typeof(watchlist) != "list" ||
!all(sapply(watchlist, inherits, 'xgb.DMatrix')))
!all(vapply(watchlist, inherits, logical(1), what = 'xgb.DMatrix')))
stop("watchlist must be a list of xgb.DMatrix elements")
evnames <- names(watchlist)
if (is.null(evnames) || any(evnames == ""))