title: Modify package function
body: <p>This is my first time trying this, so apologies if I get the terminology wrong. There's a package (snapCGH on bioconductor) that I'm using. I call one function, plotSegmentedGenome, which in turn calls genomePlot. Both functions are within the snapCGH namespace: </p>
  
  <pre><code>&gt; environment(plotSegmentedGenome)
  &lt;environment: namespace:snapCGH&gt;
  &gt; environment(genomePlot)
  &lt;environment: namespace:snapCGH&gt;
  </code></pre>
  
  <p>I want to modify genomePlot. My first attempt consisted of simply running</p>
  
  <pre><code>&gt; genomePlot
  </code></pre>
  
  <p>So I could get the code and create a new function from that. Two minor things I'd like to change. It labels the x-axis in mb whereas Id like it bp (so multiplying the labels but no the values plotted by 1000000). Secondly, it labels the x-axis additionally with the chromosome in a jarring red. Id like to remove that label totally. Saved this attempt as genomePlot.R and sourced it. </p>
  
  <p>If I then run plotSegmentedGenome then nothing changes. So I presume it's still using the genomePlot function within its namespace. If I create my own copy of plotSegmentedGenome in the global env, then I get an error "Error: object 'chrominfo.Mb' not found". This is one of the arguments for plotSegmentedGenome which I suppose is created in the env. </p>
  
  <p>I hope this makes sense and that there's a solution that isnt embarrisingly easy :) </p>
  
  <p>ps: I read this, <a href="http://www.r-bloggers.com/environments-in-r/" rel="noreferrer">http://www.r-bloggers.com/environments-in-r/</a>, which was interesting but not quite detailed enough to let me figure out how to do fix this. If only I  could write </p>
  
  <pre><code>snapCGH$genomePlot &lt;- customGenomePlot
  or 
  snapCGH:::genomePlot &lt;- customGenomePlot
  </code></pre>
  
  <p>Update: 
  Based on <a href="https://stackoverflow.com/questions/8204008/redirect-intercept-function-calls-within-a-package-function">Redirect/intercept function calls within a package function</a></p>
  
  <p>I tried </p>
  
  <pre><code> library(proto)
    plotSegmentedGenome &lt;- with(proto(environment( plotSegmentedGenome),  plotSegmentedGenome = snapCGH:: plotSegmentedGenome, genomePlot = genomePlot), my_genomePlot)
  </code></pre>
  
  <p>But I still received the error</p>
  
  <pre><code> Error in plotSegmentedGenome(SegInfo.Hom.runDNAcopy, array = array, chrom.to.plot = 19,  : 
     object 'chrominfo.Mb' not found
    &gt; 
  </code></pre>
  
  <p>It is calling my version of the function at least though, as it prints the message("its alive!") I stuck in my_genomePlot</p>