title: Need to conditionally apply function to every element in a character matrix
body: <p>I'm trying to generate a table that only consists of numbers and "" (blank spaces). I need the numbers to be formatted using scientific notation. The issue is, is that if I make this matrix of a numeric type, then I can't use "" since it is not a number, but I need it to be a blank space. If I make this matrix of character type, then the 'scientific' function from the scales library does not recognize the numbers since they are numeric type. If I try to write an if statement within a for loop that iterates through every element in my matrix, then the condition is only applied to the first element generating the following error below: </p>
  
  <blockquote>
    <p>Error in if (moduleTraitPvalueSig != "") { : 
     missing value where TRUE/FALSE needed
    In addition: Warning message:
    In if (moduleTraitPvalueSig != "") { :
    the condition has length > 1 and only the first element will be used</p>
  </blockquote>
  
  <p>I am using a matrix called moduleTraitPvalueSig, and the code that geneates the error above is as such</p>
  
  <pre><code>library(scales)
  moduleTraitPvalueSig &lt;- moduleTraitPvalue;
  moduleTraitPvalueSig[moduleTraitPvalueSig&gt;=0.05]&lt;- ""
  for(row in 1:nrow(moduleTraitPvalueSig)) {
    for(col in 1:ncol(moduleTraitPvalueSig)) {
      if(moduleTraitPvalueSig!="")
      {scientific(moduleTraitPvalueSig)}
    }
  }
  </code></pre>
  
  <blockquote>
    <p>Error in if (moduleTraitPvalueSig != "") { : </p>
    
    <p>missing value where TRUE/FALSE needed</p>
    
    <p>In addition: Warning message:</p>
    
    <p>In if (moduleTraitPvalueSig != "") { :</p>
    
    <p>the condition has length > 1 and only the first element will be used</p>
  </blockquote>