title: Error: number of items to replace is not a multiple of replacement length in R
body: <p>I am currently trying to test for collinearity amongst my climate raster layers using the 'vifcor' function in R. However I keep getting this error:</p>
  <pre><code>Error in m[, i] &lt;- getValues(x@layers[[i]]) : 
    number of items to replace is not a multiple of replacement length
  </code></pre>
  <p>My full R code is as follows:</p>
  <pre><code>predictors.files &lt;- list.files(path=&quot;/Users/josh/Desktop/Predictors/&quot;,pattern='asc$',full.names=TRUE)
  
  preds.stack&lt;-stack(predictors.files)
  vif(preds.stack)
  v1&lt;-vifcor(preds.stack,th=0.7)
  </code></pre>
  <p>Then it goes wrong. Can anyone help me with this issue?</p>
  <p>The output of <code>str(preds.stack)</code></p>
  <pre><code>Formal class 'RasterStack' 
  
  [package &quot;raster&quot;] with 11 slots ..@ filename: chr &quot;&quot; ..@ layers :List of 19 .. ..$ :Formal class 'RasterLayer' 
  
  [package &quot;raster&quot;] with 12 slots .. .. .. ..@ file :Formal class '.RasterFile' 
  
  [package &quot;raster&quot;] with 13 slots .. .. .. .. .. ..@ name : chr &quot;/Users/josh/Desktop/Predictors/isothermality.asc&quot; .. .. .. .. .. ..@ datanotation: chr &quot;FLT4S&quot; .. .. .. .. .. ..@ byteorder : chr &quot;little&quot; .. .. .. .. .. ..@ nodatavalue : num -Inf .. .. .. .. .. ..@ NAchanged : logi FALSE
  </code></pre>
  <p>Thanks :)</p>