Running ‘rasterList_fitdistr.R’ [11s/17s]
  Running ‘test_crop.R’ [20s/30s]
Running the tests in ‘tests/rasterList_fitdistr.R’ failed.
Complete output:
  > # This is a test script for rasterList function
  > # 
  > # Author: Emanuele Cordano
  > ###############################################################################
  > rm(list=ls())
  > 
  > library(rasterList)
  Loading required package: raster
  Loading required package: sp
  > library(lmom)
  > 
  > 
  > 
  > ## TESTING R CODE: 
  > library(testthat)
  > context("Verfiy Probabibilty Distribution")
  > 
  > ## It is Raster Examples:
  > 
  > precf <- system.file("map/precipitation.grd", package="rasterList")
  > 
  > prec <- stack(precf)
  > 
  > ### Or you can use Mekrou examples: 
  > ## Yearly Precipitaion on Mecrow
  > 
  > precf <- system.file("map/Mekrou_precipitation.grd", package="rasterList")
  > pvalf <- system.file("map/Mekrou_pvalkstest.grd", package="rasterList")
  > 
  > 
  > prec <- stack(precf)
  > pval <- raster(pvalf)
  > 
  > ## Set time
  > 
  > time <- as.Date(names(prec),format="X%Y.%m.%d")
  > year <- as.character(time,format="X%Y")
  Warning message:
  In as.character.POSIXt(as.POSIXlt(x), ...) :
    as.character(td, ..) no longer obeys a 'format' argument; use format(td, ..) ?
  > 
  > ## Compute Annual Precipitation (sum aggregration)
  > yearlyprec <- stackApply(x=prec,fun=sum,indices=year)
  > 
  > 
  > ## L-moments
  > 
  > 
  > samlmom <- stack(rasterList(yearlyprec,FUN=samlmu))
  > 
  > ## lmrd plot 
  > 
  > lmrd(as.data.frame(samlmom),cex=0.3)
  > 
  > 
  > ## 
  > ## These are all parametric distribution described in "lmom" packages: 
  > ## distribs <- c("exp","gam","gev","glo","gno","gpa","gum","kap","ln3","nor","pe3","wak","wei")
  > distribs <- c("gam","pe3")
  > pels <- paste("pel",distribs,sep="")
  > cdfs <- paste("cdf",distribs,sep="")
  > names(pels) <- distribs
  > names(cdfs) <- distribs
  > ##
  > ##
  > ##
  > nn <- names(pels)
  > 
  > cdfs <- cdfs[nn]
  > pels <- pels[nn]
  > 
  > ## FIT AND KSTESTING 
  > fitPrec_gam <- rasterList(samlmom,FUN=pelgam)
  > kstest_gam  <- RasterListApply(x=rasterList(yearlyprec),para=fitPrec_gam,y="cdfgam",FUN=ks.test)
  There were 31 warnings (use warnings() to see them)
  > pvalkstest <- raster(rasterList(kstest_gam,FUN=function(x) {return(x$p.value)}))	
  > test <- as.vector(pvalkstest-pval)
  > test0 <- rep(0,length(test))
  > 
  > #
  > #####
  > #xxx <- '/STORAGE/projects/R-Packages/rasterList/inst/map/Mekrou_pvalkstest.grd' 
  > #
  > #writeRaster(pvalkstest,file=xxx,overwrite=TRUE)
  > #
  > #
  > #####
  > test_that(desc="Testing final Results",code=expect_equal(test,test0, tolerance = .002, scale = 1))
  ── Failure (???): Testing final Results ────────────────────────────────────────
  `test` not equal to `test0`.
  273/273 mismatches (average diff: 0.768)
  [1] -0.882 - 0 == -0.882
  [2] -0.777 - 0 == -0.777
  [3] -0.660 - 0 == -0.660
  [4] -0.764 - 0 == -0.764
  [5] -0.297 - 0 == -0.297
  [6] -0.482 - 0 == -0.482
  [7] -0.535 - 0 == -0.535
  [8] -0.840 - 0 == -0.840
  [9] -0.753 - 0 == -0.753
  ...
  
  Error in reporter$stop_if_needed() : Test failed
  Calls: test_that -> <Anonymous>
  Execution halted