Losing ability to graph a data frame after using cbind

In my data set I have an Object that, in addition to a large data frame has a seperate section of meta data where additional information is stored about each column of the data set.

The graphing function I am working with will only accept the data frame matrix and not the object, so I simply extract it using as.data.frame and this works fine.

However there is a section of the meta data that I would like to add to the actual data matrix and use for identification and annotation within this graphing function.

I have tried almost every conceivable way to append this data to the extracted data.frame, and in doing so, I always get the error:

Error in heatmap(dataset) : 
  'x' must be a numeric matrix

The column of meta data I have is simple integers. I extract it out using as.data.frame or as.matrix. I append it using cbind, I check the type, the class, everything and its fine. I will even rerun as.matrix or as.data.frame back through to make sure everything is a numeric matrix, and I still get this error.

I have tried using cbind.data.frame also and this doesn't work I still get this error.

Does anyone know why, or I would also be happy to provide additinal examples and code if you think it would helpful.

The function by the way is called heatmap.2

Thanks so much for any advice

Not knowing what you are working with, I will take a shot in the dark. I am suspicious about using as.data.frame on the original Object. What is the structure of the original Object? Can you show us the result of calling str() on it or say what function produces it?

The most useful thing you could post is a minimal Reproducible Example. If possible, make a small data set that can be fed into whatever function produces your Object then show that code plus the plotting step that fails.

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