[R] Conjunction and disjunction in pubmed query

David Winsemius dwinsemius at comcast.net
Fri Dec 28 09:42:53 CET 2012

On Dec 27, 2012, at 3:10 PM, email wrote:

> Hi:
> I am trying to query pubmed abstracts using the following syntax:
> url= "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?"
> search = paste(url, "db=pubmed&term=", queryTerm1, "+AND+",
> queryTerm2,"+OR+",queryTerm3, "+OR+", queryTerm4,
> "[abstract]&retmax=100&usehistory=y", sep="")

I get an error here:

Error in paste(url, "db=pubmed&term=", queryTerm1, "+AND+",  
queryTerm2,  :
   object 'queryTerm1' not found

> docId <- xmlTreeParse(getURL(paste(url, search, sep="")),
> useInternalNodes=TRUE)
> I want to fetch abstracts containing queryTerm1 AND queryTerm2
> Or queryTerm3 OR queryTerm4. The code runs without error, but from the
> result I find that conjunction and disjunction is not working.

"Not working" is a phrase that conveys very little. What exactly are  
you seeing, and how is it different than what you expected to see.

> Can anyone
> suggest a correct  syntax for doing AND and OR pubmed query?

Reviewing an earlier question
  [Subject: Re: [R] query multiple terms in PubMed abstract
	Date: 	December 11, 2012]
  I find that you did not reply to my earlier response where I said  
your code was returning expected results and asked what problems were  
prompting your questions. If you do not respond to questions and fail  
to include complete code, there is little people will be able to do.  
You need to provide complete code and a more complete problem  

  If I were interested in articles the had MeSH headings for  
"mortality" and "leukemia" I would first attempt constructing a search  
phrase that looked like "mortality[mh] AND leukemia[mh]" rather than  
"mortality[mh]+AND+leukemia[mh]". But I see that the "+" symbol seemed  
to succeed last time. You may need to use parentheses to get the  
intended grouping of PubMed  search expressions.


David Winsemius, MD
Alameda, CA, USA

More information about the R-help mailing list