diff --git a/R-package/NAMESPACE b/R-package/NAMESPACE index fab1546a2..cce209811 100644 --- a/R-package/NAMESPACE +++ b/R-package/NAMESPACE @@ -25,6 +25,7 @@ importFrom(data.table,":=") importFrom(data.table,as.data.table) importFrom(data.table,copy) importFrom(data.table,data.table) +importFrom(data.table,fread) importFrom(data.table,rbindlist) importFrom(data.table,set) importFrom(data.table,setnames) diff --git a/R-package/R/xgb.dump.R b/R-package/R/xgb.dump.R index 7cb1c524a..cc22bb3a7 100644 --- a/R-package/R/xgb.dump.R +++ b/R-package/R/xgb.dump.R @@ -3,8 +3,10 @@ #' Save a xgboost model to text file. Could be parsed later. #' #' @importFrom magrittr %>% -#' @importFrom stringr str_split #' @importFrom stringr str_replace +#' @importFrom data.table fread +#' @importFrom data.table := +#' @importFrom data.table setnames #' @param model the model object. #' @param fname the name of the text file where to save the model text dump. If not provided or set to \code{NULL} the function will return the model as a \code{character} vector. #' @param fmap feature map file representing the type of feature. @@ -46,7 +48,9 @@ xgb.dump <- function(model = NULL, fname = NULL, fmap = "", with.stats=FALSE) { stop("fmap: argument must be type character (when provided)") } - dt <- .Call("XGBoosterDumpModel_R", model, fmap, as.integer(with.stats), PACKAGE = "xgboost") %>% fread + longString <- .Call("XGBoosterDumpModel_R", model, fmap, as.integer(with.stats), PACKAGE = "xgboost") + + dt <- fread(paste(longString, collapse = ""), sep = "\n", header = F) setnames(dt, "Content") diff --git a/R-package/man/xgboost.Rd b/R-package/man/xgboost.Rd index 8c8a384f4..59480e36c 100644 --- a/R-package/man/xgboost.Rd +++ b/R-package/man/xgboost.Rd @@ -91,7 +91,7 @@ Number of threads can also be manually specified via "nthread" parameter. \item \code{ndcg} Normalized Discounted Cumulative Gain. \url{http://en.wikipedia.org/wiki/NDCG} } -More parameters are available in the Wiki \url{https://github.com/tqchen/xgboost/wiki/Parameters} +More parameters are available in the Wiki \url{https://github.com/tqchen/xgboost/wiki/Parameters}. } \examples{ data(agaricus.train, package='xgboost')