title: R run correlation, ignoring non-numeric data
body: <p>I am trying to run a correlation between all numberic values (the dataset contains columns of both numeric and non-numeric values) using the following code:</p>
  
  <pre><code>mydata= read.csv("C:\\full_path\\playerData.csv", header = TRUE)
  mydata=data.frame(mydata)
  vals=cor(mydata, use="complete.obs", method="pearson") 
  write.csv(vals,"C:\\Users\\weiler\\Desktop\\RStudioOutput.csv")
  </code></pre>
  
  <p>based on this site: <a href="http://www.statmethods.net/stats/correlations.html" rel="noreferrer">http://www.statmethods.net/stats/correlations.html</a> I am getting the error: </p>
  
  <blockquote>
    <p>Error in cor(mydata, use = "complete.obs", method = "pearson") : 'x' must be numeric</p>
  </blockquote>
  
  <p>My error seems to be because some of the data is non-numeric. Is there a simple way to ignore the non-numeric data?</p>