Skip to content
Snippets Groups Projects
Verified Commit 105a670c authored by Gärber, Florian's avatar Gärber, Florian
Browse files

fix: Using if() conditions comparing class() to string

Now using inherits()
parent 6c3ad33e
No related branches found
No related tags found
No related merge requests found
...@@ -91,7 +91,7 @@ var.relations = function(x = NULL, y = NULL, num.trees = 500, type = "regression ...@@ -91,7 +91,7 @@ var.relations = function(x = NULL, y = NULL, num.trees = 500, type = "regression
stop("Too much classes defined, classification might be the wrong choice") stop("Too much classes defined, classification might be the wrong choice")
} }
} }
if (type == "regression" && class(y) == "factor") { if (type == "regression" && inherits(y, "factor")) {
stop("use factor variable for y only for classification! ") stop("use factor variable for y only for classification! ")
} }
......
...@@ -93,7 +93,7 @@ var.relations.mfi = function(x = NULL, y = NULL, num.trees = 500, type = "regres ...@@ -93,7 +93,7 @@ var.relations.mfi = function(x = NULL, y = NULL, num.trees = 500, type = "regres
stop("Too much classes defined, classification might be the wrong choice") stop("Too much classes defined, classification might be the wrong choice")
} }
} }
if (type == "regression" && class(y) == "factor") { if (type == "regression" && inherits(y, "factor")) {
stop("use factor variable for y only for classification! ") stop("use factor variable for y only for classification! ")
} }
......
...@@ -110,7 +110,7 @@ var.select.mir = function(x = NULL, y = NULL, num.trees = 500, type = "regressio ...@@ -110,7 +110,7 @@ var.select.mir = function(x = NULL, y = NULL, num.trees = 500, type = "regressio
stop("Too much classes defined, classification might be the wrong choice") stop("Too much classes defined, classification might be the wrong choice")
} }
} }
if (type == "regression" && class(y) == "factor") { if (type == "regression" && inherits(y, "factor")) {
stop("use factor variable for y only for classification! ") stop("use factor variable for y only for classification! ")
} }
......
...@@ -112,7 +112,7 @@ var.select.smd = function(x = NULL, y = NULL, num.trees = 500, type = "regressio ...@@ -112,7 +112,7 @@ var.select.smd = function(x = NULL, y = NULL, num.trees = 500, type = "regressio
stop("Too much classes defined, classification might be the wrong choice") stop("Too much classes defined, classification might be the wrong choice")
} }
} }
if (type == "regression" && class(y) == "factor") { if (type == "regression" && inherits(y, "factor")) {
stop("use factor variable for y only for classification! ") stop("use factor variable for y only for classification! ")
} }
data = data.frame(y, x) data = data.frame(y, x)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment