Hi all,

I get the following Error:

    Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)

I'm trying to make a heatmap (pheatmap package) using K means. 
I have a large matrix (x) and I did the following:

    x[x < 0] <- NA
    
    x2 <- x[complete.cases(x),]
    
    RedBlue <- colorRampPalette(c("blue", "white", "red")) (20)
    
    pheatmap(x2, scale="row", kmeans_k=100, cluster_rows=TRUE, cluster_cols=TRUE, clustering_method = "ward.D2",color=RedBlue, legend=FALSE, show_colnames=TRUE, fontsize=15, fontface="bold", border_color=NA, width=20, heigth=100, cellwidth=30, cellheight = 5, show_rownames = FALSE, filename = "Heatmap.tiff")

I checked for NA/NaN/Inf but I don't have this is my matrix. What can be another reason for this error?

Thanks!



This is not a bioinformatics question. Also before posting in a more appropriate channel, provide a reproducible example.  
Now since I am here...   
This error can happen for several reasons the most common being:  
- presence of NAs, including those produced by scale() in the case of variables with 0 variance  
- presence of non-numerical values