title: in R, use gsub to remove all punctuation except period
body: <p>I am new to R so I hope you can help me.</p>
  
  <p>I want to use gsub to remove all punctuation except for periods and minus signs so I can keep decimal points and negative symbols in my data.</p>
  
  <p><strong>Example</strong></p>
  
  <p>My data frame z has the following data:</p>
  
  <pre><code>     [,1] [,2]   
  [1,] "1"  "6"    
  [2,] "2@"  "7.235"
  [3,] "3"  "8"    
  [4,] "4"  "$9"   
  [5,] "£5" "-10" 
  </code></pre>
  
  <p>I want to use <code>gsub("[[:punct:]]", "", z)</code> to remove the punctuation. </p>
  
  <p><strong>Current output</strong></p>
  
  <pre><code>&gt; gsub("[[:punct:]]", "", z)
       [,1] [,2]  
  [1,] "1"  "6"   
  [2,] "2"  "7235"
  [3,] "3"  "8"   
  [4,] "4"  "9"   
  [5,] "5"  "10" 
  </code></pre>
  
  <p>I would like, however, to keep the "-" sign and the "." sign.</p>
  
  <p><strong>Desired output</strong></p>
  
  <pre><code> PSEUDO CODE:  
  &gt; gsub("[[:punct:]]", "", z, except(".", "-") )
           [,1] [,2]  
      [1,] "1"  "6"   
      [2,] "2"  "7.235"
      [3,] "3"  "8"   
      [4,] "4"  "9"   
      [5,] "5"  "-10" 
  </code></pre>
  
  <p>Any ideas how I can make some characters exempt from the gsub() function?</p>