compounds <- c("C00022", "C00153", "C00216", "C01167") organism <- c("M00008") 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")) } }
- create a function that takes a kegg compound id and a vector of organism ids. - The function should return a logical vector indicating whether the compound belongs to the organism(s) passed to the function. - Use the function to check whether compounds in `compounds` belong to organism(s) in `organism`