largeRCRF/R/Numeric.R

29 lines
797 B
R
Raw Permalink Normal View History

#' Numeric
#'
2019-07-23 18:55:46 +00:00
#' An internal function that converts an R vector of numerics or integers into
#' an R list containing java.lang.Double objects. This method does not need to
#' be used directly by the user, as \code{\link{train}} will automatically
#' handle numeric responses if you're working in the regression settings.
#' @param y The R vector of numbers
#' @export
#' @return An R list containing rJava Doubles.
#' @keywords internal
#' @examples
#' x <- Numeric(1:5)
#' class(x[[1]])
Numeric <- function(y){
y <- as.double(y)
javaList <- .jcall(.class_RUtils,
makeResponse(.class_List),
"importNumericResponse",
y)
responses <- list(javaObject=javaList, y=y)
class(responses) <- "JNumeric"
return(responses)
}