non-numeric argument to 'pairs' in R

1

I was trying to make a correlation matrix with the scatterplotMatrix() command in R and get this error:

  

scatterplotMatrix (a_heterophylla_NAY_SIN, spread = FALSE, lty.smooth = 2,   main="Matrix correlations") Error in pairs.default (x, labels =   var.labels, cex.axis = cex.axis, cex.main = cex.main,:
  non-numeric argument to 'pairs'

What does it mean and how do I resolve it? Please help !!

    
asked by Gabi Quesada A 18.09.2017 в 21:58
source

1 answer

0

I will try to answer your question based on the information you gave. Fundamentally the problem is data, particularly in a_heterophylla_NAY_SIN , the error triggers when scatterplotMatrix() invokes internally pairs() assigning the x parameter to your a_heterophylla_NAY_SIN object, if you see the documentation:

  

x: the coordinates of points given as numeric columns of a matrix or   data frame Logical and factor columns are converted to numeric in the   same way that data.matrix does.

That is, a matrix or a dataframe is expected and fundamentally all values must be "mapped" to numerical values. Reviewing the code of pairs() , we see:

if (!is.matrix(x)) {
        x <- as.data.frame(x)
        for(i in seq_along(names(x))) {
            if(is.factor(x[[i]]) || is.logical(x[[i]]))
               x[[i]] <- as.numeric(x[[i]])
            if(!is.numeric(unclass(x[[i]])))
                stop("non-numeric argument to 'pairs'")
        }
    } else if (!is.numeric(x)) stop("non-numeric argument to 'pairs'")

That is, o a_heterophylla_NAY_SIN is a non-numeric matrix or an object that is still mapped as a dataframe, some of its columns are not numeric. The solution would then go through "normalize" a_heterophylla_NAY_SIN , and eventually convert any non-numeric value into a Factor, so that it can be processed correctly.

    
answered by 19.09.2017 / 04:12
source