title: <0 rows> (or 0-length row.names)
body: <p>I've read the other pages on stack exchange on this topic and I still cant figure out why <code>selectedSub &lt;- subset(corList, (abs(cor) &gt; 0.2 &amp; j == 'Income'))</code> is returning the error &lt;0 rows> (or 0-length row.names). </p>
  
  <pre><code># Url
  library(RCurl)
  urlfile &lt;- 'https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data'
  
  x &lt;- getURL(urlfile, ssl.verifypeer = FALSE)
  
  #Read csv
  adults &lt;- read.csv(textConnection(x), header = F)
  
  head(adults,2)
  
  # Change the header names
  names(adults) = c('Age', 'Workclass', 'FinalWeight', 'Eductation',  'EducationNumber',
                'MaritalStatus', 'Occupation', 'Relationship', 'Race', 
                'Sex', 'CapitalGain', 'CapitalLoss', 'HoursWeek', 
                'NativeCountry', 'Income') 
  
  # Change to binary
  adults$Income &lt;- ifelse(adults$Income ==' &lt;= 50k', 0,1)
  
  # Change all the factors to numbers
  library(caret)
  dmy &lt;- dummyVars(" ~.", data = adults)
  adultsTrsf &lt;- data.frame(predict(dmy, newdata = adults))
  dim(adultsTrsf)
  head(adultsTrsf)
  
  ## Correlation matrix with p-values.
  cor.prob &lt;- function (X, dfr = nrow(X) - 2) {
  R &lt;- cor(X, use="pairwise.complete.obs")
  above &lt;- row(R) &lt; col(R)
  r2 &lt;- R[above]^2
  Fstat &lt;- r2 * dfr/(1 - r2)
  R[above] &lt;- 1 - pf(Fstat, 1, dfr)
  R[row(R) == col(R)] &lt;- NA
  R
  }
  
  ## Use this to dump the cor.prob output to a 4 column matrix
  ## with row/column indices, correlation, and p-value.
  flattenSquareMatrix &lt;- function(m) {
  if( (class(m) != "matrix") | (nrow(m) != ncol(m))) stop("Must be a square matrix.")
  if(!identical(rownames(m), colnames(m))) stop("Row and column names must be equal.")
  ut &lt;- upper.tri(m)
  data.frame(i = rownames(m)[row(m)[ut]],
           j = rownames(m)[col(m)[ut]],
           cor=t(m)[ut],
           p=m[ut])
  }
  
  ##
  corMasterList &lt;- flattenSquareMatrix (cor.prob(adultsTrsf))
  
  # Order by absolute correlation value
  corList &lt;- corMasterList [order(-abs(corMasterList$cor)),]
  
  ##
  head(corList)
  
  ##
  selectedSub &lt;- subset(corList, (abs(cor) &gt; 0.2 &amp; j == 'Income'))
  
  ## 
  selectedSub
  </code></pre>