diff --git a/R-package/.Rbuildignore b/R-package/.Rbuildignore index 6b3c4084e..b37d627ba 100644 --- a/R-package/.Rbuildignore +++ b/R-package/.Rbuildignore @@ -3,3 +3,4 @@ \.dll$ ^.*\.Rproj$ ^\.Rproj\.user$ +README.md diff --git a/R-package/DESCRIPTION b/R-package/DESCRIPTION index c6975af5e..6f784fbb3 100644 --- a/R-package/DESCRIPTION +++ b/R-package/DESCRIPTION @@ -5,7 +5,7 @@ Version: 0.4-0 Date: 2015-05-11 Author: Tianqi Chen , Tong He , Michael Benesty Maintainer: Tong He -Description: Xgboost is short for eXtreme Gradient Boosting, which is an +Description: eXtreme Gradient Boosting, which is an efficient and scalable implementation of gradient boosting framework. This package is an R wrapper of xgboost. The package includes efficient linear model solver and tree learning algorithms. The package can automatically diff --git a/R-package/R/utils.R b/R-package/R/utils.R index f7f6b9192..e58601df8 100644 --- a/R-package/R/utils.R +++ b/R-package/R/utils.R @@ -288,7 +288,7 @@ xgb.cv.aggcv <- function(res, showsd = TRUE) { } ret <- paste(ret, sprintf("%f", mean(stats)), sep="") if (showsd) { - ret <- paste(ret, sprintf("+%f", sd(stats)), sep="") + ret <- paste(ret, sprintf("+%f", stats::sd(stats)), sep="") } } return (ret) @@ -313,7 +313,7 @@ xgb.createFolds <- function(y, k = 10) if(cuts < 2) cuts <- 2 if(cuts > 5) cuts <- 5 y <- cut(y, - unique(quantile(y, probs = seq(0, 1, length = cuts))), + unique(stats::quantile(y, probs = seq(0, 1, length = cuts))), include.lowest = TRUE) } diff --git a/R-package/R/xgb.cv.R b/R-package/R/xgb.cv.R index 793d904cd..a5364db52 100644 --- a/R-package/R/xgb.cv.R +++ b/R-package/R/xgb.cv.R @@ -240,7 +240,7 @@ xgb.cv <- function(params=list(), data, nrounds, nfold, label = NULL, missing = else colnames <- colnamesMean type <- rep(x = "numeric", times = length(colnames)) - dt <- read.table(text = "", colClasses = type, col.names = colnames) %>% as.data.table + dt <- utils::read.table(text = "", colClasses = type, col.names = colnames) %>% as.data.table split <- str_split(string = history, pattern = "\t") for(line in split) dt <- line[2:length(line)] %>% str_extract_all(pattern = "\\d*\\.+\\d*") %>% unlist %>% as.numeric %>% as.list %>% {rbindlist(list(dt, .), use.names = F, fill = F)} diff --git a/R-package/R/xgb.plot.importance.R b/R-package/R/xgb.plot.importance.R index eb0f8e346..b86d14323 100644 --- a/R-package/R/xgb.plot.importance.R +++ b/R-package/R/xgb.plot.importance.R @@ -33,7 +33,7 @@ xgb.plot.importance <- function(importance_matrix = NULL, numberOfClusters = c(1 if (!"data.table" %in% class(importance_matrix)) { stop("importance_matrix: Should be a data.table.") } - if (!require(ggplot2, quietly = TRUE)) { + if (!requireNamespace(ggplot2, quietly = TRUE)) { stop("ggplot2 package is required for plotting the importance", call. = FALSE) } if (!requireNamespace("Ckmeans.1d.dp", quietly = TRUE)) { @@ -46,7 +46,7 @@ xgb.plot.importance <- function(importance_matrix = NULL, numberOfClusters = c(1 clusters <- suppressWarnings(Ckmeans.1d.dp::Ckmeans.1d.dp(importance_matrix[,Gain], numberOfClusters)) importance_matrix[,"Cluster":=clusters$cluster %>% as.character] - plot <- ggplot(importance_matrix, aes(x=reorder(Feature, Gain), y = Gain, width= 0.05), environment = environment())+ geom_bar(aes(fill=Cluster), stat="identity", position="identity") + coord_flip() + xlab("Features") + ylab("Gain") + ggtitle("Feature importance") + theme(plot.title = element_text(lineheight=.9, face="bold"), panel.grid.major.y = element_blank() ) + plot <- ggplot(importance_matrix, aes(x=stats::reorder(Feature, Gain), y = Gain, width= 0.05), environment = environment())+ geom_bar(aes(fill=Cluster), stat="identity", position="identity") + coord_flip() + xlab("Features") + ylab("Gain") + ggtitle("Feature importance") + theme(plot.title = element_text(lineheight=.9, face="bold"), panel.grid.major.y = element_blank() ) return(plot) }