In public health research and more precisely in the reuse of electronic health data, selecting patients, identifying specific events and interpreting results typically requires biomedical knowledge. The queryMed R package aims to facilitate the integration of medical and pharmacological knowledge stored in formats compliant with the Linked Data paradigm (e.g. OWL ontologies and RDF datasets) into the R statistical programming environment. We show how it allowed us to identify all the drugs prescribed for critical limb ischemia (CLI) and also to detect one contraindicated prescription for one patient by linking a medical database of 1003 CLI patients to ontologies.