-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Issue
I encountered this error when executing plotting/plot_survey_fits.R. The error occurs in line 135 but is due to how the function generate_post_pred() is written. In line 50 a condition is tested in an if statement, but a logical vector may be supplied (rather than a single boolean) which is what happens in the use case on line 135.
Solution
Replace
if(is.na(mask)){
data[data == 0] <- NA
}else{
mask <- which(as.numeric(as.vector(mask))==1)
data[,as.vector(unique(mask))] <- NA
}
with
if(all(is.na(mask))) {
data[data == 0] <- NA
} else {
data[,mask] <- NA
}
This merely tests whether mask has any NA's in it to supply a single boolean. It may or may not be the best solution. The second part in the else code is just a simplification.
pws-herring-basa/plotting/plot_survey_fits.R
Lines 50 to 55 in caef7da
| if(is.na(mask)){ | |
| data[data == 0] <- NA | |
| }else{ | |
| mask <- which(as.numeric(as.vector(mask))==1) | |
| data[,as.vector(unique(mask))] <- NA | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels