Skip to content

Error on trivial example #7

@DavorJ

Description

@DavorJ

Hi Giulio, I am currently testing your package for consistency on some trivial cases, and got the following error with the below example with only 1 possible stratum per domain:

strata <- data.frame(
  "STRATO" = LETTERS[1:5],
  "N" = c(471114, 179296,  150211,  88104, 270184 + 20000)*100,
  "M1" = c(61.08, 89.19, 89.50, 76.41, 76.59),
  "S1" = c(19.91, 28.19, 35.03, 37.14, 31.40),
  "COST" = 1, "CENS" = 0, 
  "DOM1" = 1:5,
  "X1" = LETTERS[1:5]
)

solution <- SamplingStrata::optimizeStrata(
  errors = data.frame("DOM" = "DOM1", "CV1" = 0.05, "domainvalue" = 1:5),
  strata = strata, showPlot = FALSE, parallel = FALSE)


#> Error in solut[[3]] : subscript out of bounds

It seems to be related to this piece of code where if nrow(stcamp[[i]]) == 1 is true, the rbga object is removed from solut, but on line 208 it is referred to.

Also,, the errors dataframe needs a specific form, but this form is nowhere clearly documented as far as I can tell. Especially domainvalue is inconsistent. On one occasion it is used as reference to a column name as in buildFrameDF(), and sometimes as an indicator value as in this case. Maybe making a constructor function with dedicated help section for this error data.frame would make things easier?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions