From a961a129a4f271f2962ce6fb9705c6f0fd704610 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20G=C3=A4rber?= <florian.gaerber@uni-hamburg.de>
Date: Tue, 27 Aug 2024 12:16:23 +0200
Subject: [PATCH] fix: No longer append .0 to selected names in short tree
 forests.

fixes #13
---
 DESCRIPTION       |  4 ++--
 NEWS.md           |  4 ++++
 R/surrmindep.R    |  1 +
 man/surrmindep.Rd | 18 ++++++++----------
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index b8f4ed7..41b6714 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
 Type: Package
 Package: RFSurrogates
 Title: Surrogate Minimal Depth Variable Importance
-Version: 0.4.0
+Version: 0.4.1
 Authors@R: c(
     person("Stephan", "Seifert", , "stephan.seifert@uni-hamburg.de", role = c("aut", "cre"),
            comment = c(ORCID = "0000-0003-2567-5728")),
@@ -36,4 +36,4 @@ LinkingTo:
 Config/testthat/edition: 3
 Encoding: UTF-8
 LazyData: true
-RoxygenNote: 7.2.3
+RoxygenNote: 7.3.2
diff --git a/NEWS.md b/NEWS.md
index be12c54..d05eb8e 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,7 @@
+# RFSurrogates 0.4.1
+
+- Fix `SurrogateMinimalDepth`'s result `$selected` returning modified names (#13)
+
 # RFSurrogates 0.4.0
 
 **Added `RandomForestSurrogates()`.**
diff --git a/R/surrmindep.R b/R/surrmindep.R
index b96fa9b..9c46ced 100644
--- a/R/surrmindep.R
+++ b/R/surrmindep.R
@@ -86,6 +86,7 @@ surrmindep <- function(forest, s.l = count.surrogates(forest$trees)$s.l) {
     p.1 <- 1 - p.root
     threshold <- p.root * 0 + p.1 * 1
     warning("Trees are very small! Threshold is defined based on trees with only root nodes.")
+    threshold <- unname(threshold)
   }
 
   if ((avgTreeHeight) >= 2) {
diff --git a/man/surrmindep.Rd b/man/surrmindep.Rd
index 82a603f..9ab6547 100644
--- a/man/surrmindep.Rd
+++ b/man/surrmindep.Rd
@@ -7,23 +7,21 @@
 surrmindep(forest, s.l = count.surrogates(forest$trees)$s.l)
 }
 \arguments{
-\item{forest}{a list containing \code{allvariables} and \code{trees}.
+\item{forest}{a list containing `allvariables` and `trees`.
 Allvariables is a vector of all variable names in the original data set (strings).
-Trees is a list of trees that was generated by \code{\link[=getTreeranger]{getTreeranger()}},
-\code{\link[=addLayer]{addLayer()}}, and \code{\link[=addSurrogates]{addSurrogates()}}.}
+Trees is a list of trees that was generated by [getTreeranger()],
+[addLayer()], and [addSurrogates()].}
 
 \item{s.l}{Number of average surrogate variables in the respective layers.
-(use \code{\link[=count.surrogates]{count.surrogates()}} function to get it)}
+(use [count.surrogates()] function to get it)}
 }
 \value{
 List with the following components:
-\itemize{
-\item \code{depth}: mean surrogate minimal depth for each variable
-\item \code{selected}: variables has been selected (1) or not (0),
-\item \code{threshold}: the threshold that is used for the selection
-}
+ * `depth`: mean surrogate minimal depth for each variable
+ * `selected`: variables has been selected (1) or not (0),
+ * `threshold`: the threshold that is used for the selection
 }
 \description{
 This function determines the surrogate minimal depth of variables from a
-forest that is created by \code{\link[=getTreeranger]{getTreeranger()}}, \code{\link[=addLayer]{addLayer()}} and \code{\link[=addSurrogates]{addSurrogates()}} functions.
+forest that is created by [getTreeranger()], [addLayer()] and [addSurrogates()] functions.
 }
-- 
GitLab