From 0662c9dfc3f97e5cb561dda889a177630042298d Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Tue, 23 Jul 2019 11:18:40 -0700 Subject: [PATCH 1/4] Fix bug where if you run tests without first installing the package, tests fail. --- R/zzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index dee42b0..8f625bd 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -4,7 +4,7 @@ # it's in the inst folder which won't be present if the package was actually # loaded from the R library). Thus with morePaths we make sure it loads up the # jar in this situation. - .jpackage(pkgname, lib.loc=libname, morePaths="inst/java/largeRCRF-1.0-SNAPSHOT.jar") + .jpackage(pkgname, lib.loc=libname, morePaths="inst/java/largeRCRF-library-1.0-SNAPSHOT.jar") } From 094fb5489efb14b3d65bf5f9252cdcee3b5bc3ec Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Tue, 23 Jul 2019 11:19:25 -0700 Subject: [PATCH 2/4] Add better error checking for the extract___ functions. --- DESCRIPTION | 2 +- R/cr_predictions.R | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 20d8762..e6081f2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: largeRCRF Type: Package Title: Large Random Competing Risks Forests -Version: 1.0.3 +Version: 1.0.3.1 Authors@R: c( person("Joel", "Therrien", email = "joel_therrien@sfu.ca", role = c("aut", "cre", "cph")), person("Jiguo", "Cao", email = "jiguo_cao@sfu.ca", role = c("aut", "dgs")) diff --git a/R/cr_predictions.R b/R/cr_predictions.R index 8c515f0..a2a982f 100644 --- a/R/cr_predictions.R +++ b/R/cr_predictions.R @@ -48,6 +48,10 @@ extractCIF <- function (x, event) { #' @export extractCIF.CompetingRiskFunctions <- function(x, event){ + if(is.null(event) | anyNA(event)){ + stop("event must be specified") + } + fun <- stats::stepfun(x$time.interest, c(0, x$cif[,event])) class(fun) <- "function" @@ -57,6 +61,10 @@ extractCIF.CompetingRiskFunctions <- function(x, event){ #' @export extractCIF.CompetingRiskFunctions.List <- function(x, event){ + if(is.null(event) | anyNA(event)){ + stop("event must be specified") + } + return(lapply(x, extractCIF.CompetingRiskFunctions, event)) } @@ -70,6 +78,10 @@ extractCHF <- function (x, event) { #' @export extractCHF.CompetingRiskFunctions <- function(x, event){ + if(is.null(event) | anyNA(event)){ + stop("event must be specified") + } + fun <- stats::stepfun(x$time.interest, c(0, x$chf[,event])) class(fun) <- "function" @@ -79,6 +91,10 @@ extractCHF.CompetingRiskFunctions <- function(x, event){ #' @export extractCHF.CompetingRiskFunctions.List <- function(x, event){ + if(is.null(event) | anyNA(event)){ + stop("event must be specified") + } + return(lapply(x, extractCHF.CompetingRiskFunctions, event)) } From e062d3f4414748509d30ca4ff850c550b2b0434e Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Tue, 23 Jul 2019 11:55:46 -0700 Subject: [PATCH 3/4] Clean up documentation --- R/CR_Response.R | 2 +- R/Numeric.R | 5 ++++- R/addTrees.R | 4 ++-- R/cr_components.R | 4 ++-- man/CR_FunctionCombiner.Rd | 2 +- man/CR_Response.Rd | 2 +- man/CR_ResponseCombiner.Rd | 2 +- man/Numeric.Rd | 5 ++++- man/addTrees.Rd | 4 ++-- 9 files changed, 18 insertions(+), 12 deletions(-) diff --git a/R/CR_Response.R b/R/CR_Response.R index 6e29d00..d8a7134 100644 --- a/R/CR_Response.R +++ b/R/CR_Response.R @@ -8,7 +8,7 @@ #' #' @param delta A vector of integers detailing the event that occurred. A value #' of 0 denotes that censoring occurred first and that time was recorded. -#' @param u A vector of numerics detailing the recorded event times (possibly +#' @param u A numeric vector detailing the recorded event times (possibly #' censored). #' @param C If the censoring times are known for all observations, they can be #' included which allows for \code{\link{GrayLogRankSplitFinder}} to be used. diff --git a/R/Numeric.R b/R/Numeric.R index 6eadf01..96259cb 100644 --- a/R/Numeric.R +++ b/R/Numeric.R @@ -1,7 +1,10 @@ #' Numeric #' -#' 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. +#' 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. diff --git a/R/addTrees.R b/R/addTrees.R index 75331ee..bb7f41a 100644 --- a/R/addTrees.R +++ b/R/addTrees.R @@ -9,8 +9,8 @@ #' @param forest An existing forest. #' @param numTreesToAdd The number of trees to add. #' @param savePath If saving the forest, the directory to save to. Default is -#' \code{NULL}. Note that you need to respecify the path if you're modifying a -#' previously saved forest. +#' \code{NULL}. Note that you need to re-specify the path if you're modifying +#' a previously saved forest. #' @param savePath.overwrite If \code{savePath} is pointing to an existing #' directory, possibly containing another forest, this specifies what should #' be done. diff --git a/R/cr_components.R b/R/cr_components.R index a958812..2e7817d 100644 --- a/R/cr_components.R +++ b/R/cr_components.R @@ -10,7 +10,7 @@ #' The user only needs to pass this object into \code{\link{train}} as the #' \code{forestResponseCombiner} parameter. #' -#' @param events A vector of integers specifying which competing risk events's +#' @param events A vector of integers specifying which competing risks event #' functions should be processed. This should correspond to all of the #' competing risk events that can occur, from 1 to the largest number. #' @param times An optional numeric vector that forces the output functions to @@ -66,7 +66,7 @@ CR_FunctionCombiner <- function(events, times = NULL){ #' The user only needs to pass this object into \code{\link{train}} as the #' \code{nodeResponseCombiner} parameter. #' -#' @param events A vector of integers specifying which competing risk events's +#' @param events A vector of integers specifying which competing risks event #' functions should be processed. This should correspond to all of the #' competing risk events that can occur, from 1 to the largest number. #' @export diff --git a/man/CR_FunctionCombiner.Rd b/man/CR_FunctionCombiner.Rd index 929ec68..9d66f19 100644 --- a/man/CR_FunctionCombiner.Rd +++ b/man/CR_FunctionCombiner.Rd @@ -7,7 +7,7 @@ CR_FunctionCombiner(events, times = NULL) } \arguments{ -\item{events}{A vector of integers specifying which competing risk events's +\item{events}{A vector of integers specifying which competing risks event functions should be processed. This should correspond to all of the competing risk events that can occur, from 1 to the largest number.} diff --git a/man/CR_Response.Rd b/man/CR_Response.Rd index a09a694..8e2c17b 100644 --- a/man/CR_Response.Rd +++ b/man/CR_Response.Rd @@ -10,7 +10,7 @@ CR_Response(delta, u, C = NULL) \item{delta}{A vector of integers detailing the event that occurred. A value of 0 denotes that censoring occurred first and that time was recorded.} -\item{u}{A vector of numerics detailing the recorded event times (possibly +\item{u}{A numeric vector detailing the recorded event times (possibly censored).} \item{C}{If the censoring times are known for all observations, they can be diff --git a/man/CR_ResponseCombiner.Rd b/man/CR_ResponseCombiner.Rd index 61a53bb..43e6017 100644 --- a/man/CR_ResponseCombiner.Rd +++ b/man/CR_ResponseCombiner.Rd @@ -7,7 +7,7 @@ CR_ResponseCombiner(events) } \arguments{ -\item{events}{A vector of integers specifying which competing risk events's +\item{events}{A vector of integers specifying which competing risks event functions should be processed. This should correspond to all of the competing risk events that can occur, from 1 to the largest number.} } diff --git a/man/Numeric.Rd b/man/Numeric.Rd index 4e3f6ae..6fc746b 100644 --- a/man/Numeric.Rd +++ b/man/Numeric.Rd @@ -13,7 +13,10 @@ Numeric(y) An R list containing rJava Doubles. } \description{ -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. +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. } \examples{ x <- Numeric(1:5) diff --git a/man/addTrees.Rd b/man/addTrees.Rd index ddeeb92..3004baf 100644 --- a/man/addTrees.Rd +++ b/man/addTrees.Rd @@ -14,8 +14,8 @@ addTrees(forest, numTreesToAdd, savePath = NULL, \item{numTreesToAdd}{The number of trees to add.} \item{savePath}{If saving the forest, the directory to save to. Default is -\code{NULL}. Note that you need to respecify the path if you're modifying a -previously saved forest.} +\code{NULL}. Note that you need to re-specify the path if you're modifying +a previously saved forest.} \item{savePath.overwrite}{If \code{savePath} is pointing to an existing directory, possibly containing another forest, this specifies what should From 4cd322ee228a367aafb5aaef7533325ddd1204e5 Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Tue, 23 Jul 2019 12:14:17 -0700 Subject: [PATCH 4/4] Quick documentation fix --- java/OBTAINING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java/OBTAINING.md b/java/OBTAINING.md index 4737ec6..0e9e7d2 100644 --- a/java/OBTAINING.md +++ b/java/OBTAINING.md @@ -1,5 +1,5 @@ -The Java source code for this package can be obtained at https://github.com/jatherrien/largeRCRF-Java, and is also licensed under the GPL-3 license. You can include it with your modifications into the R package by following these steps: - -* Delete the Jar file in `inst/java/` -* Build the Java code in its own separate directory using `mvn clean package` in the root of the directory (same folder containing `README.md`). Make sure you have [Maven](https://maven.apache.org/) installed. -* Copy the `library/target/largeRCRF-library/1.0-SNAPSHOT.jar` file produced in the Java directory into `inst/java/` \ No newline at end of file +The Java source code for this package can be obtained at https://github.com/jatherrien/largeRCRF-Java, and is also licensed under the GPL-3 license. You can include it with your modifications into the R package by following these steps: + +* Delete the Jar file in `inst/java/` +* Build the Java code in its own separate directory using `mvn clean package` in the root of the directory (same folder containing `README.md`). Make sure you have [Maven](https://maven.apache.org/) installed. +* Copy the `library/target/largeRCRF-library-1.0-SNAPSHOT.jar` file produced in the Java directory into `inst/java/` \ No newline at end of file