From f4b454d6ddbb7b8fa91266bd126140c044dab42f Mon Sep 17 00:00:00 2001 From: pommedeterresautee Date: Mon, 9 Feb 2015 21:34:53 +0100 Subject: [PATCH] fix some warning in Cran check --- R-package/R/xgb.dump.R | 8 ++++---- R-package/man/xgb.save.raw.Rd | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 R-package/man/xgb.save.raw.Rd diff --git a/R-package/R/xgb.dump.R b/R-package/R/xgb.dump.R index cc22bb3a7..edeb03b5f 100644 --- a/R-package/R/xgb.dump.R +++ b/R-package/R/xgb.dump.R @@ -52,13 +52,13 @@ xgb.dump <- function(model = NULL, fname = NULL, fmap = "", with.stats=FALSE) { dt <- fread(paste(longString, collapse = ""), sep = "\n", header = F) - setnames(dt, "Content") + setnames(dt, "Lines") if(is.null(fname)) { - result <- dt[Content != "0"][,Content := str_replace(Content, "^\t+", "")][Content != ""][,paste(Content)] + result <- dt[Lines != "0"][, Lines := str_replace(Lines, "^\t+", "")][Lines != ""][, paste(Lines)] return(result) } else { - result <- dt[Content != "0"][Content != ""][,paste(Content)] %>% writeLines(fname) + result <- dt[Lines != "0"][Lines != ""][, paste(Lines)] %>% writeLines(fname) return(TRUE) } } @@ -66,4 +66,4 @@ xgb.dump <- function(model = NULL, fname = NULL, fmap = "", with.stats=FALSE) { # Avoid error messages during CRAN check. # The reason is that these variables are never declared # They are mainly column names inferred by Data.table... -globalVariables(".") \ No newline at end of file +globalVariables(c("Lines", ".")) \ No newline at end of file diff --git a/R-package/man/xgb.save.raw.Rd b/R-package/man/xgb.save.raw.Rd new file mode 100644 index 000000000..15ec30636 --- /dev/null +++ b/R-package/man/xgb.save.raw.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2 (4.1.0): do not edit by hand +% Please edit documentation in R/xgb.save.raw.R +\name{xgb.save.raw} +\alias{xgb.save.raw} +\title{Save xgboost model to R's raw vector, +user can call xgb.load to load the model back from raw vector} +\usage{ +xgb.save.raw(model) +} +\arguments{ +\item{model}{the model object.} +} +\description{ +Save xgboost model from xgboost or xgb.train +} +\examples{ +data(agaricus.train, package='xgboost') +data(agaricus.test, package='xgboost') +train <- agaricus.train +test <- agaricus.test +bst <- xgboost(data = train$data, label = train$label, max.depth = 2, + eta = 1, nround = 2,objective = "binary:logistic") +raw <- xgb.save(bst) +bst <- xgb.load(raw) +pred <- predict(bst, test$data) +} +