x error must be numeric

Asked

Viewed 956 times

0

I’m learning to work with the R yet. I’m trying to build a dendrogram from correlation tests, between isotopic and meteorological data. I did the following:

RC <- read.csv("RCmatrix.csv")
head(RC)
dim(RC)
summary (RC)
cormat <- round(cor(RC),2)
Quando chego aqui aparece: Error in cor(RC) : 'x' deve ser numérico

head(cormat)
dim(cormat)

library(heatmaply)
heatmaply(cor(RC), margins = c(40,130),
          k_col = 2, k_row = 2, colors = Spectral, seriate = "OLO",
          limits = c(-1,1))

My data matrix has 288 rows and 18 columns.

  • 1

    Look, with a piece of code makes it easier to help, you can use dput(head(RC)). I recommend trying on the console class(RC) or typeof(RC) to see if it is in numerical format.

  • The summary should give a clue. What kind of data are all numerical? Also try str(RC) and run the cor only for numerical columns, class "numeric" or "integer".

  • i_col <- sapply(RC, class) %in% c("integer", "numeric");cor(RC[which(i_col)])

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.