How to use corrplot with is.corr=FALSE

Viewed 4002

I previously made a beautiful functional and perfect actual corrolation plot with corrplot (my plot). Now I have to get the underlying data in the same look. So my goal is to have triangular similarity matrixes in the same colours as my corrolation plot. Imagine it like the conditional formatting in excel.

My Data: my Data from excel

Link to CSV Data file

it is loaded in as a csv and it can read the csv perfectly

My Code:corrplot(Phylogeny, is.corr=FALSE,method="number", cl.lim=c(0,1))

The error it throws me: Error in if (any(corr < cl.lim[1]) || any(corr > cl.lim[2])) { : Missing value, where TRUE/FALSE is required

  • i made sure all colums are numeric
  • i made sure to fill the missing bits with NA's (because that was a problem somwhere before)
  • i made sure all my values are between 0 and 1 like i want the limit to be (in between it told me that my values are not within the limit, when i tried around with some stuff)
  • the error does not change when i change the limit
  • the error does not change when i take the is.corr=FALSE out (default=TRUE)
  • i played around with corrplot.mixed and its still not working
  • have been referencing information from Corrplot Intro

I have looked into the condformat function but i am not really sure if it can do a filling of each cell with one colour according to the overall gradient like i used for my corrolation plot.

What am I missing here that it does not want to give me my table back with pretty colours?

2 Answers

I had the same error, but I was able to fix it by converting my data.frame to a matrix. I ended up with corrplot(as.matrix(df), is.corr = FALSE).

If I am understanding correctly, your posted data are already a correlation matrix - although not a fully symmetrical one of the sort that would be produced with the call cor on raw data.

In that case, the problem is just that you have variable names (Species) as a column in your data. Change this column to row names, drop the variable names, and call corrplot as user9536160 suggests:

# read in your data    
phyl <- as.data.frame(read_csv("Phylogeny.csv"))

# name rows and drop variable names in the df itself
row.names(phyl) <- phyl$Species
phyl <- phyl %>%
  select(-Species)

# call corrplot
corrplot(as.matrix(phyl), is.corr = FALSE)

The result:

corrplot result

Related