for (compound in compounds) { compound_info <- keggFind("compound", compounds) if(length(compound_info$organism) > 0) { cat(paste(compound, "belongs to", organism, "\n")) } else { cat(paste(compound, "has no associated organism(s) in KEGG\n")) } }
The function is used to test whether a given compound is associated with a specific organism.