You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
part_sblock is using && operators with vectors that have length bigger than 1 and is causing an error
Description of error
When calling part_sblock, the following error is printed to the console
Error in unique(Opt2$spa_auto) && unique(Opt2$env_sim) :
'length = 5' in coercion to 'logical(1)'
Possible cause
I've read a bit of the codebase searching for the line that is giving that error and found it inside the file R/part_sblock.R on line 606. Here's the line with surrounding code that might be relevant:
# file: R/part_sblock.R# Code...# SELLECTION OF THE BEST CELL SIZE----Opt2<-Opt# Line 564
rownames(Opt2) <- colnames(part)
Dup<-if (any(unique(pa) ==0)) {
!duplicated(Opt2[c("spa_auto", "env_sim", "sd_p", "sd_a")])
} else {
!duplicated(Opt2[c("spa_auto", "env_sim", "sd_p")])
}
Opt2<-Opt2[Dup, ]
while (nrow(Opt2) >1) {
# I MORANif (nrow(Opt2) ==1) {
break
}
Opt2<-Opt2[which(Opt2$spa_auto<= summary(Opt2$spa_auto)[2]), ]
if (nrow(Opt2) ==1) {
break
}
# EuclideanOpt2<-Opt2[which(Opt2$env_sim>= summary(Opt2$env_sim)[5]), ]
if (nrow(Opt2) ==1) {
break
}
# SD presenceOpt2<-Opt2[which(Opt2$sd_p<= summary(Opt2$sd_p)[2]), ]
if (nrow(Opt2) ==2) {
break
}
# SD absencesif (any(unique(pa) ==0)) {
Opt2<-Opt2[which(Opt2$sd_a<= summary(Opt2$sd_a)[2]), ]
if (nrow(Opt2) ==2) {
break
}
}
if (unique(Opt2$spa_auto) &&# Line 606 - ERROR HAPPENS HERE!
unique(Opt2$env_sim) && unique(Opt2$sd_p)) {
Opt2<-Opt2[nrow(Opt2), ]
}
}
if (nrow(Opt2) >1) {
Opt2<-Opt2[nrow(Opt2), ]
}
# More code...
I'm pretty sure the error is caused by this change in R version 4.3.0:
You can access the page I got this information here.
Possible fix
Basically the problem is that && and || now give errors when one of the evaluated arguments has a length bigger than 1. Originally these operators would simply use the first element of the vector, so I believe the equivalent code would be:
if (unique(Opt2$spa_auto)[1] &&
unique(Opt2$env_sim)[1] && unique(Opt2$sd_p)[1]) {
Opt2<-Opt2[nrow(Opt2), ]
}
Extra notes
I don't know how to program in R or what the intention of this statement is, I'm just trying to help a friend that has no formal education in programming and ended up getting this error. I'm sorry, but I'm not able to provide more context, like steps to reproduce or which data was fed into the function, right now. However I think that you can fix this without more context, but, if needed, just ask for it and I'll try to get it with my friend.
The text was updated successfully, but these errors were encountered:
part_sblock is using
&&
operators with vectors that have length bigger than 1 and is causing an errorDescription of error
When calling
part_sblock
, the following error is printed to the consolePossible cause
I've read a bit of the codebase searching for the line that is giving that error and found it inside the file
R/part_sblock.R
on line 606. Here's the line with surrounding code that might be relevant:I'm pretty sure the error is caused by this change in R version 4.3.0:
You can access the page I got this information here.
Possible fix
Basically the problem is that
&&
and||
now give errors when one of the evaluated arguments has a length bigger than 1. Originally these operators would simply use the first element of the vector, so I believe the equivalent code would be:Extra notes
I don't know how to program in R or what the intention of this statement is, I'm just trying to help a friend that has no formal education in programming and ended up getting this error. I'm sorry, but I'm not able to provide more context, like steps to reproduce or which data was fed into the function, right now. However I think that you can fix this without more context, but, if needed, just ask for it and I'll try to get it with my friend.
The text was updated successfully, but these errors were encountered: