corrplot error "must have >=2 objects to cluster"

I'm trying to create a corrplot using the following code
M<-cor(my_data[, unlist(lapply(data, is.numeric))])
corrplot(M, type="upper", order="hclust",
col=brewer.pal(n=8, name="RdYlBu"))

but it is showing this error
Error in hclust(as.dist(1 - corr), method = hclust.method) :
must have n >= 2 objects to cluster

My data looks like this

> my_data
                                         X.group shallow_cell       inlet   deep_cell
1                                  methanotrophy  0.000000000 0.000177873 0.000000000
2                             methanol_oxidation  0.000333731 0.000554544 0.000051300
3                                  methylotrophy  0.000333731 0.000721954 0.000051300
4                                   fermentation  0.114612634 0.093383138 0.013174082
5                      aerobic_chemoheterotrophy  0.118140644 0.054052357 0.429823662
6               aromatic_hydrocarbon_degradation  0.000381406 0.003452822 0.001281526

As written, that will not work because there is no object named data to use in
lapply(data, is.numeric).
I think R will use the built in function data(), return all FALSE for is.numeric and you end up with no data.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.