Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have found the same problem with this function in the past, so now I looked a little deeper. The help page for <code>biovars</code> states that it will accept three arguments that are vectors, matrices, or rasterStack/Bricks. For these three cases, the arguments should have respectively length, width, or depth of 12 months, and the return value will have length, width or depth of 19.</p> <p>The help page example for 3 vector arguments returns a vector of 19 values. This works fine.</p> <pre><code>tmin.V &lt;- c(10,12,14,16,18,20,22,21,19,17,15,12) tmax.V &lt;- tmin.V + 5 prec.V &lt;- c(0,2,10,30,80,160,80,20,40,60,20,0) biovars(prec.V, tmin.V, tmax.V) </code></pre> <p>An example with three 2x12 matrices returns a 2x19 matrix, also works fine.</p> <pre><code>tmin.M &lt;- rbind(tmin.V, tmin.V+1) tmax.M &lt;- rbind(tmax.V, tmax.V+1) prec.M &lt;- rbind(prec.V, prec.V+1) biovars(prec.M, tmin.M, tmax.M) </code></pre> <p>But with rasterstacks and rasterbricks you do not get 19 values. I believe this is a bug. I ran <code>biovars</code> on real *.bil data from worldclim.org and duplicated your result of a 12-value answer. I tried to use the dummy code below which returns an error (not clear why), but may be useful if you want to explain your problem to R. Hijmans in detail. I also get the same error when I call biovars using worldclim *.bil data that has been cropped.</p> <pre><code>dup12 &lt;- function(clim.M) { raslist = list() for(i in 1:12) raslist = c(raslist, raster(clim.M)) do.call(stack, raslist) } tmin.S &lt;- dup12(tmin.M) tmax.S &lt;- dup12(tmax.M) prec.S &lt;- dup12(prec.M) biovars(prec.S, tmin.S, tmax.S) Error in v[tr$row[i]:(tr$row[i] + tr$nrows[i] - 1), ] &lt;- p : number of items to replace is not a multiple of replacement length </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload