improve document format

This commit is contained in:
hetong 2014-08-30 15:14:36 -07:00
parent 2c1aabf6b0
commit a06f01e8ec
6 changed files with 27 additions and 9 deletions

View File

@ -4,20 +4,23 @@ setClass('xgb.DMatrix')
#' #'
#' Get information of an xgb.DMatrix object #' Get information of an xgb.DMatrix object
#' #'
#' @param object Object of class "xgb.DMatrix"
#' @param name the name of the field to get
#'
#' @examples #' @examples
#' data(iris) #' data(iris)
#' iris[,5] <- as.numeric(iris[,5]) #' iris[,5] <- as.numeric(iris[,5])
#' dtrain <- xgb.DMatrix(as.matrix(iris[,1:4]), label=iris[,5]) #' dtrain <- xgb.DMatrix(as.matrix(iris[,1:4]), label=iris[,5])
#' labels <- getinfo(dtrain, "label") #' labels <- getinfo(dtrain, "label")
#' @rdname getinfo
#' @export #' @export
#' #'
getinfo <- function(object, ...){ getinfo <- function(object, ...){
UseMethod("getinfo") UseMethod("getinfo")
} }
#' @param object Object of class "xgb.DMatrix"
#' @param name the name of the field to get
#' @param ... other parameters
#' @rdname getinfo
#' @method getinfo xgb.DMatrix
setMethod("getinfo", signature = "xgb.DMatrix", setMethod("getinfo", signature = "xgb.DMatrix",
definition = function(object, name) { definition = function(object, name) {
if (typeof(name) != "character") { if (typeof(name) != "character") {

View File

@ -6,22 +6,25 @@ setClass('xgb.DMatrix')
#' Get a new DMatrix containing the specified rows of #' Get a new DMatrix containing the specified rows of
#' orginal xgb.DMatrix object #' orginal xgb.DMatrix object
#' #'
#' @param object Object of class "xgb.DMatrix"
#' @param idxset a integer vector of indices of rows needed
#'
#' @examples #' @examples
#' data(iris) #' data(iris)
#' iris[,5] <- as.numeric(iris[,5]) #' iris[,5] <- as.numeric(iris[,5])
#' dtrain <- xgb.DMatrix(as.matrix(iris[,1:4]), label=iris[,5]) #' dtrain <- xgb.DMatrix(as.matrix(iris[,1:4]), label=iris[,5])
#' dsub <- slice(dtrain, 1:3) #' dsub <- slice(dtrain, 1:3)
#' @rdname slice
#' @export #' @export
#' #'
slice <- function(object, ...){ slice <- function(object, ...){
UseMethod("slice") UseMethod("slice")
} }
#' @param object Object of class "xgb.DMatrix"
#' @param idxset a integer vector of indices of rows needed
#' @param ... other parameters
#' @rdname slice
#' @method slice xgb.DMatrix
setMethod("slice", signature = "xgb.DMatrix", setMethod("slice", signature = "xgb.DMatrix",
definition = function(object, idxset) { definition = function(object, idxset, ...) {
if (class(object) != "xgb.DMatrix") { if (class(object) != "xgb.DMatrix") {
stop("slice: first argument dtrain must be xgb.DMatrix") stop("slice: first argument dtrain must be xgb.DMatrix")
} }

View File

@ -2,7 +2,7 @@
#' #'
#' Save xgb.DMatrix object to binary file #' Save xgb.DMatrix object to binary file
#' #'
#' @param model the model object. #' @param DMatrix the model object.
#' @param fname the name of the binary file. #' @param fname the name of the binary file.
#' #'
#' @examples #' @examples

View File

@ -1,14 +1,20 @@
% Generated by roxygen2 (4.0.1): do not edit by hand % Generated by roxygen2 (4.0.1): do not edit by hand
\docType{methods}
\name{getinfo} \name{getinfo}
\alias{getinfo} \alias{getinfo}
\alias{getinfo,xgb.DMatrix-method}
\title{Get information of an xgb.DMatrix object} \title{Get information of an xgb.DMatrix object}
\usage{ \usage{
getinfo(object, ...) getinfo(object, ...)
\S4method{getinfo}{xgb.DMatrix}(object, name)
} }
\arguments{ \arguments{
\item{object}{Object of class "xgb.DMatrix"} \item{object}{Object of class "xgb.DMatrix"}
\item{name}{the name of the field to get} \item{name}{the name of the field to get}
\item{...}{other parameters}
} }
\description{ \description{
Get information of an xgb.DMatrix object Get information of an xgb.DMatrix object

View File

@ -1,15 +1,21 @@
% Generated by roxygen2 (4.0.1): do not edit by hand % Generated by roxygen2 (4.0.1): do not edit by hand
\docType{methods}
\name{slice} \name{slice}
\alias{slice} \alias{slice}
\alias{slice,xgb.DMatrix-method}
\title{Get a new DMatrix containing the specified rows of \title{Get a new DMatrix containing the specified rows of
orginal xgb.DMatrix object} orginal xgb.DMatrix object}
\usage{ \usage{
slice(object, ...) slice(object, ...)
\S4method{slice}{xgb.DMatrix}(object, idxset, ...)
} }
\arguments{ \arguments{
\item{object}{Object of class "xgb.DMatrix"} \item{object}{Object of class "xgb.DMatrix"}
\item{idxset}{a integer vector of indices of rows needed} \item{idxset}{a integer vector of indices of rows needed}
\item{...}{other parameters}
} }
\description{ \description{
Get a new DMatrix containing the specified rows of Get a new DMatrix containing the specified rows of

View File

@ -6,7 +6,7 @@
xgb.DMatrix.save(DMatrix, fname) xgb.DMatrix.save(DMatrix, fname)
} }
\arguments{ \arguments{
\item{model}{the model object.} \item{DMatrix}{the model object.}
\item{fname}{the name of the binary file.} \item{fname}{the name of the binary file.}
} }