Skip to content

Commit e3f624d

Browse files
authored
[R] remove more uses of default values in internal functions (dmlc#9476)
1 parent 2c84dae commit e3f624d

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

R-package/R/xgb.DMatrix.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ xgb.DMatrix <- function(data, info = list(), missing = NA, silent = FALSE, nthre
8888

8989
# get dmatrix from data, label
9090
# internal helper method
91-
xgb.get.DMatrix <- function(data, label = NULL, missing = NA, weight = NULL, nthread = NULL) {
91+
xgb.get.DMatrix <- function(data, label, missing, weight, nthread) {
9292
if (inherits(data, "dgCMatrix") || is.matrix(data)) {
9393
if (is.null(label)) {
9494
stop("label must be provided when data is a matrix")

R-package/R/xgb.cv.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,13 @@ xgb.cv <- function(params = list(), data, nrounds, nfold, label = NULL, missing
194194

195195
# create the booster-folds
196196
# train_folds
197-
dall <- xgb.get.DMatrix(data, label, missing, nthread = params$nthread)
197+
dall <- xgb.get.DMatrix(
198+
data = data,
199+
label = label,
200+
missing = missing,
201+
weight = NULL,
202+
nthread = params$nthread
203+
)
198204
bst_folds <- lapply(seq_along(folds), function(k) {
199205
dtest <- slice(dall, folds[[k]])
200206
# code originally contributed by @RolandASc on stackoverflow

R-package/R/xgb.ggplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ normalize <- function(x) {
183183
# ... the plots
184184
# cols number of columns
185185
# internal utility function
186-
multiplot <- function(..., cols = 1) {
186+
multiplot <- function(..., cols) {
187187
plots <- list(...)
188188
num_plots <- length(plots)
189189

R-package/R/xgboost.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ xgboost <- function(data = NULL, label = NULL, missing = NA, weight = NULL,
1010
save_period = NULL, save_name = "xgboost.model",
1111
xgb_model = NULL, callbacks = list(), ...) {
1212
merged <- check.booster.params(params, ...)
13-
dtrain <- xgb.get.DMatrix(data, label, missing, weight, nthread = merged$nthread)
13+
dtrain <- xgb.get.DMatrix(
14+
data = data,
15+
label = label,
16+
missing = missing,
17+
weight = weight,
18+
nthread = merged$nthread
19+
)
1420

1521
watchlist <- list(train = dtrain)
1622

0 commit comments

Comments
 (0)