fix some warning in Cran check

This commit is contained in:
pommedeterresautee 2015-02-09 21:34:53 +01:00
parent a3cf30592f
commit f4b454d6dd
2 changed files with 31 additions and 4 deletions

View File

@ -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(".")
globalVariables(c("Lines", "."))

View File

@ -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)
}