yufree / xMSannotator

fork from https://sourceforge.net/projects/xmsannotator/
https://sourceforge.net/projects/xmsannotator/
9 stars 13 forks source link

Error in if (queryadductlist == "all" & mode == "pos") {: the condition has length >1 #9

Closed ratleyge closed 1 year ago

ratleyge commented 1 year ago

Hi, Thank you so much for putting xMSAnnotator on GitHub. I am trying to run HMDB.Annotation with adducts c("M+2H", "M+Na", "M+H") keep getting the error:

Error in if (queryadductlist == "all" & mode == "pos") {: the condition has length >1

Basically I receive this error any time I try to use adducts other than "all". Even the default settings return this error. I have been able to run the code before, but recently updated my version of R and something seems to have broken. I hope this is enough information, but I am happy to provide more as needed. Thank you for your help in advance!

ratleyge commented 1 year ago

To fix, the line of simpleAnnotation should be changed from:

if (queryadductlist == "all" & mode == "pos") {

to:

if (all(queryadductlist == "all") & mode == "pos") {

This also needs to be done for the next if statement:

if (all(queryadductlist == "all") & mode == "neg") {

I am able to run the function with this change.

yufree commented 1 year ago

Thanks. I didn't realize the issue in simpleAnnotation function. It should be fixed now. Such error is generated due to the fact that if statement will not accept vector in R 4.x version. If you are using R 3.x version, you might not have this error. Anyway, such issue should be fixed now and let me know if you have other issue.

ratleyge commented 1 year ago

Ah that makes sense. Thank you so much!