Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: "condition has length > 1 and only the first element will be used" #23

Closed
warnes opened this issue Feb 6, 2021 · 1 comment

Comments

@warnes
Copy link

warnes commented Feb 6, 2021

Using iRF version 3.0.0 installed yesterday from GitHub, I get this warning message:

Warning message:
In if (!class(x) %in% c("data.frame", "matrix")) { :
  the condition has length > 1 and only the first element will be used

when x is of class c("matrix", "array"). This is originating from

iRF/R/iRF.R

Lines 93 to 97 in 7476536

if (!class(x) %in% c('data.frame', 'matrix')) {
sp.mat <- attr(class(x), 'package') == 'Matrix'
if (is.null(sp.mat) || !sp.mat)
stop('x must be matrix or data frame')
}

This can be resolved by replacing class(x) %in% c("data.frame", "matrix") with is(x, c("data.frame", "matrix") here, as well as elsewhere in the code.

Example:

set.seed(42)
x <- structure(c(0.51542, 0.61489, 0.63492, 0.53612, 0.52895, 0.64572,  0.54093, 0.48915, 0.56444, 0.62533, 0.48457, 0.52632, 0.52961,  0.65015, 0.54746, 0.53074, 0.54062, 0.51413, 0.58454, 0.57131,  0.26293, 0.29376, 0.28257, 0.27655, 0.27326, 0.23358, 0.28784,  0.31006, 0.28066, 0.25501, 0.28015, 0.2786, 0.24955, 0.27152,  0.2051, 0.20854, 0.28254, 0.30097, 0.27195, 0.24717), .Dim = c(10L,  4L), .Dimnames = list(NULL, c("CGI_69.PDR.Set1", "CGI_223.PDR.Set1",  "CGI_299.PDR.Set1", "CGI_550.PDR.Set1")))
 y <- sample(factor(c("0","1")), size=10, replace=TRUE)

r <- iRF(x=x, y=y)
## [1] "iteration =  1"
## [1] "iteration =  2"
## [1] "iteration =  3"
## [1] "iteration =  4"
## [1] "iteration =  5"
## Warning message:
## In if (!class(x) %in% c("data.frame", "matrix")) { :
##   the condition has length > 1 and only the first element will be used## Warning message:
@karlkumbier
Copy link
Collaborator

The warning message has been resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants