title: New gplots update in R cannot find function distfun in heatmap.2
body: <p>I have a bit of R-code to make a heatmap from a correlation matrix, which worked the last time I used it (prior to the 2013 Oct 17 update of gplots; after updating to R Version 3.0.2). This makes me think that something changed in the most recent gplots update, but I can not figure out what.</p>
  
  <p>What used to present a nice plot now gives me this error:</p>
  
  <blockquote>
    <p>" Error in hclustfun(distfun(x)) : could not find function "distfun" "</p>
  </blockquote>
  
  <p>and won't plot anything. Below is the code to reproduce the plot (heavily commented as I was using it to teach an undergrad how to use heatmaps for a project). I tried adding the last line to explicitly set the functions, but it didn't help resolve the problem.</p>
  
  <p>EDIT: I changed the last line of code to read: 
     ,distfun =function(c) {as.dist(1-c,upper=FALSE)}, hclustfun=hclust)
  and it worked. When I used just "dist=as.dist" I got a plot, but it wasn't sorted right, and several of the dendrogram branches didn't connect to the tree. Not sure what happened, or why this is working, but it appears to be.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks in advance,</p>
  
  <pre><code>library(gplots)
  set.seed(12345)
  
  randData &lt;- as.data.frame(matrix(rnorm(600),ncol=6))
  
  randDataCorrs &lt;- randData+(rnorm(600))
  names(randDataCorrs) &lt;- paste(names(randDataCorrs),"_c",sep="")
  randDataExtra &lt;- cbind(randData,randDataCorrs)
  
  randDataExtraMatrix &lt;- cor(randDataExtra)
  
  
  heatmap.2(randDataExtraMatrix, # sets the correlation matrix to use
            symm=TRUE, #tells whether it is symmetrical or not
            main= "Correlation matrix\nof Random Data Cor", # Names plot
            xlab= "x groups",ylab="", # Sets the x and y labels
            scale="none", # Tells it not to scale the data
            col=redblue(256),# Sets the colors (can be manual, see below) 
            trace="none", # tells it not to add a trace
            symkey=TRUE,symbreaks=TRUE, # Tells it to keep things symmetric around 0
            density.info = "none"#) # can be "histogram" if you want a hist of your corr values here
            #,distfun=dist, hclustfun=hclust)
            ,distfun =function(c) {as.dist(1-c,upper=FALSE)}, hclustfun=hclust) # new last line
  </code></pre>