From 9fc32bdc2e32d9b42eaaa3d3bf30d95fe1017173 Mon Sep 17 00:00:00 2001 From: Marvin Wright Date: Fri, 30 Nov 2018 08:27:44 +0100 Subject: [PATCH] change conindex to accept Surv() objects --- DESCRIPTION | 6 +++--- R/perfomances.R | 9 ++++++--- man/conindex.Rd | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 29dad83..6d6adb1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: survivalsvm Type: Package Title: Survival Support Vector Analysis -Version: 0.0.5 -Date: 2018-01-05 +Version: 0.0.6 +Date: 2018-11-30 Author: Cesaire J. K. Fouodo Maintainer: Cesaire Fouodo Description: Performs support vectors analysis for data sets with survival @@ -24,6 +24,6 @@ Suggests: Depends: survival License: GPL -RoxygenNote: 6.0.1 +RoxygenNote: 6.1.0 URL: https://github.com/imbs-hl/survivalsvm BugReports: https://github.com/imbs-hl/survivalsvm/issues diff --git a/R/perfomances.R b/R/perfomances.R index 6162b08..8690176 100644 --- a/R/perfomances.R +++ b/R/perfomances.R @@ -4,7 +4,7 @@ #' @param obj [\code{survivalsvmprediction}]\cr #' Object of class \code{survivalsvmprediction}. #' @param Y [\code{vector}(1)]\cr -#' A numeric vector of truth survival times obeserved. +#' A \code{Surv()} object with true survival times observed. #' #' @export #' @return [\code{Integer}] @@ -17,9 +17,12 @@ conindex <- function(obj, Y){ if (is.null(obj$predicted)) { stop("Error: field 'predicted' not found in 'obj'.") } + if (!is.Surv(Y)) { + stop("Error: Y must be a Surv() object.") + } X <- obj$predicted - if (length(X) != length(Y)) { - stop("Error: lengths do not macht.") + if (length(X) != nrow(Y)) { + stop("Error: lengths do not match.") } ci = Hmisc::rcorr.cens(x = X, S = Y) return(ci["C Index"]) diff --git a/man/conindex.Rd b/man/conindex.Rd index b6c1370..5fe12aa 100644 --- a/man/conindex.Rd +++ b/man/conindex.Rd @@ -11,7 +11,7 @@ conindex(obj, Y) Object of class \code{survivalsvmprediction}.} \item{Y}{[\code{vector}(1)]\cr -A numeric vector of truth survival times obeserved.} +A \code{Surv()} object with true survival times observed.} } \value{ [\code{Integer}]