Running ‘multiResGrid.R’ [30s/35s]
Running the tests in ‘tests/multiResGrid.R’ failed.
Complete output:
  > s1 = Sys.time()
  > library(MRG)
  > library(tidyr)
  > library(dplyr)
  
  Attaching package: 'dplyr'
  
  The following objects are masked from 'package:stats':
  
      filter, lag
  
  The following objects are masked from 'package:base':
  
      intersect, setdiff, setequal, union
  
  > # Neccessary to silence sf startup messages
  > suppressMessages(library(sf))
  > if (require(giscoR, quietly = TRUE)) {
  + # Read nuts borders, used for extracting smaller data set 
  +   borders = gisco_get_nuts(nuts_level = 2)
  +   dkb = borders[borders$CNTR_CODE == "DK",] %>% st_transform(crs = 3035)
  + } else {
  +   mrgpath = find.package("MRG")
  +   load(file.path(mrgpath, "ex/dkb.rda"))
  + }
  > #'
  > # These are SYNTHETIC agricultural FSS data 
  > data(ifs_dk) # Census data
  > ifs_weight = ifs_dk %>% dplyr::filter(Sample == 1) # Extract weighted subsample
  > 
  > # Create spatial data
  > ifg = fssgeo(ifs_dk, locAdj = "LL")
  > fsg = fssgeo(ifs_weight, locAdj = "LL")
  > 
  > ifg$dkb = st_join(ifg, dkb)$NUTS_ID
  > ifg = ifg[!is.na(ifg$dkb) & ifg$dkb == "DK01",]
  > fsg$dkb = st_join(fsg, dkb)$NUTS_ID
  > fsg = fsg[!is.na(fsg$dkb) & fsg$dkb == "DK01",]
  > 
  > ifg$ft = as.numeric(substr(ifg$FARMTYPE, 3, 4))^2
  > 
  > s2 = Sys.time()
  > #'
  > # Set the base resolutions, and create a hierarchical list with gridded data
  > ress = c(1,5,10,20,40)*1000
  > # Gridding Utilized agricultural area (UAA), organic UAA and ft together
  > ifl = gridData(ifg, c("UAA", "UAAXK0000_ORG", "ft"), res = ress)
  > 
  > # Gridding the UAA from the survey - the survey weights are in the column EXT_MODULE
  > fsl = gridData(fsg,  vars = c("UAA"), weights = "EXT_MODULE",  res = ress)
  > 
  > # Create a multi-resolution grid only with farm number as confidentiality rule, then plot results
  > himg0 = multiResGrid(ifl, checkReliability = FALSE, suppresslim = 0)
  [1] "ires 2 5000 #himg-cells: 117 ; removed: 1209 ; added: 108 ; confidential: 9"
  [1] "ires 3 10000 #himg-cells: 79 ; removed: 58 ; added: 20 ; confidential: 5"
  [1] "ires 4 20000 #himg-cells: 68 ; removed: 14 ; added: 3 ; confidential: 2"
  [1] "ires 5 40000 #himg-cells: 56 ; removed: 13 ; added: 1 ; confidential: 1"
  > 
  > # Create a multi-resolution grid of UAA, also based on the dominance rule (default)
  > himg1 = multiResGrid(ifl, vars = "UAA", ifg = ifg)
  [1] "ires 2 5000 #himg-cells: 117 ; removed: 1209 ; added: 108 ; confidential: 9"
  [1] "ires 3 10000 #himg-cells: 79 ; removed: 58 ; added: 20 ; confidential: 5"
  [1] "ires 4 20000 #himg-cells: 67 ; removed: 16 ; added: 4 ; confidential: 2"
  [1] "ires 5 40000 #himg-cells: 48 ; removed: 21 ; added: 2 ; confidential: 1"
  > 
  > # Create joint multi-resolution grid of organic UAA
  > himg2 = multiResGrid(ifl, vars = "UAAXK0000_ORG", ifg = ifg, 
  +                      checkReliability = FALSE, suppresslim = 0)
  [1] "ires 2 5000 #himg-cells: 298 ; removed: 1002 ; added: 82 ; confidential: 0"
  [1] "ires 3 10000 #himg-cells: 67 ; removed: 263 ; added: 32 ; confidential: 3"
  [1] "ires 4 20000 #himg-cells: 29 ; removed: 50 ; added: 12 ; confidential: 3"
  [1] "ires 5 40000 #himg-cells: 20 ; removed: 14 ; added: 5 ; confidential: 2"
  > 
  > # Create joint multi-resolution grid of organic UAA and total UAA
  > himg3 = multiResGrid(ifl, vars = c("UAA", "UAAXK0000_ORG"), ifg = ifg, 
  +                   checkReliability = FALSE, suppresslim = 0)
  [1] "ires 2 5000 #himg-cells: 117 ; removed: 1209 ; added: 108 ; confidential: 9"
  [1] "ires 3 10000 #himg-cells: 41 ; removed: 109 ; added: 33 ; confidential: 6"
  [1] "ires 4 20000 #himg-cells: 18 ; removed: 35 ; added: 12 ; confidential: 5"
  [1] "ires 5 40000 #himg-cells: 9 ; removed: 14 ; added: 5 ; confidential: 3"
  > 
  > 
  > # Create joint multi-resolution grid of organic UAA and total UAA, with suppression
  > himg4 = multiResGrid(ifl, vars = c("UAA", "UAAXK0000_ORG"), ifg = ifg, 
  +                      checkReliability = FALSE, suppresslim = 0.1)
  [1] "ires 2 5000 #himg-cells: 117 ; removed: 1209 ; added: 108 ; confidential: 9"
  [1] "ires 3 10000 #himg-cells: 41 ; removed: 109 ; added: 33 ; confidential: 6"
  [1] "ires 4 20000 #himg-cells: 18 ; removed: 35 ; added: 12 ; confidential: 5"
  [1] "ires 5 40000 #himg-cells: 16 ; removed: 4 ; added: 2 ; confidential: 7"
  > 
  > # Create joint multi-resolution grid of ft
  > himg5 = multiResGrid(ifl, vars = c("ft"), ifg = ifg, 
  +                      checkReliability = FALSE, suppresslim = 0.1)
  [1] "ires 2 5000 #himg-cells: 117 ; removed: 1209 ; added: 108 ; confidential: 9"
  [1] "ires 3 10000 #himg-cells: 90 ; removed: 43 ; added: 16 ; confidential: 9"
  [1] "ires 4 20000 #himg-cells: 85 ; removed: 7 ; added: 2 ; confidential: 6"
  > 
  > himg6 = multiResGrid(ifl, vars = c("UAA", "UAAXK0000_ORG", "ft"), ifg = ifg, 
  +                      checkReliability = FALSE, suppresslim = 0.1)
  [1] "ires 2 5000 #himg-cells: 117 ; removed: 1209 ; added: 108 ; confidential: 9"
  [1] "ires 3 10000 #himg-cells: 41 ; removed: 109 ; added: 33 ; confidential: 6"
  [1] "ires 4 20000 #himg-cells: 18 ; removed: 35 ; added: 12 ; confidential: 5"
  [1] "ires 5 40000 #himg-cells: 16 ; removed: 4 ; added: 2 ; confidential: 7"
  > 
  > himg7 = MRGmerge(himg1, himg2, himg3 = himg5)
  Warning messages:
  1: attribute variables are assumed to be spatially constant throughout all geometries 
  2: attribute variables are assumed to be spatially constant throughout all geometries 
  > 
  > s3 = Sys.time()
  > 
  > 
  > # Create multi-resolution grid of UAA and organic UAA, based on survey data,
  > # also applying reliability check
  > himg5 <-  multiResGrid(fsl, vars = c("UAA"), weights = "EXT_MODULE", ifg = fsg, 
  +                       strat = "STRA_ID_CORE", checkReliability = TRUE, reliabilitySplit = 5)
  Error in `[.data.table`(var_z_hi, , `:=`((paste0("var_", namY)), lapply(.SD[,  : 
    attempt access index 220/220 in VECTOR_ELT
  Calls: multiResGrid ... mrg_varestim -> vardom -> variance_est -> [ -> [.data.table
  Execution halted