A bug in save_probabilities()
was raising warnings in R>4.2 (that would have be ome an error in R>4.3) when saving the probabilities for multiple variables.
The warnings in question:
Warning messages:
1: In (!is.character(filename)) || (nchar(filename) < 1) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
2: In (nc$filename == "IN-MEMORY") || (!nc$writable) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
Instead of passing the variable
parameter to the get_filename()
function, which contains only the name of the variable currently handled in the for loop, the call to the function was directly using the variable names in the s2dv_cube
. This caused the function to generate two different output filenames, instead of a single filename as expected.
This merge request fixes the error, eliminating the warnings and guaranteeing that the probability files for each variable have the correct names when saved to the output directory.