rvalavi / blockCV

The blockCV package creates spatially or environmentally separated training and testing folds for cross-validation to provide a robust error estimation in spatially structured environments. See
https://doi.org/10.1111/2041-210X.13107
GNU General Public License v3.0
109 stars 24 forks source link

get error when running spatialBlock #6

Closed immaryw closed 5 years ago

immaryw commented 5 years ago

Hi there,

I got an error "Error in [[<-.data.frame(*tmp*, i, value = c(5, 1, 5, 2, 1, 2, 4, : replacement has 51 rows, data has 52" when running the function spatialBlock. I did a simulation of 10 runs. The first two work well, but get this error in the third run. Do you have some thoughts?

Thanks!

immaryw commented 5 years ago

When I change the selection from "random" to "systematic", I get a similar error: "Error in data.frame(blocks = seq_len(nrowBlocks), folds = systematicNum(subBlocks, : arguments imply differing number of rows: 49, 50"

Traceback: 3: stop(gettextf("arguments imply differing number of rows: %s", paste(unique(nrows), collapse = ", ")), domain = NA) 2: data.frame(blocks = seq_len(nrowBlocks), folds = systematicNum(subBlocks, k)) 1: spatialBlock(speciesData = even[[i]], theRange = range1[[i]], k = 5, selection = "systematic", iteration = 100, xOffset = 0, yOffset = 0, showBlocks = FALSE)

rvalavi commented 5 years ago

@immaryw thanks for the reporting the issue. Could you please provide me with more information about your data or if you can give an example data I can more specifically check track the issue.

immaryw commented 5 years ago

@rvalavi I changed theRange argument and solved the problem. Thanks!