Question: Pubmed Query using R
0
gravatar for krushnach80
3.3 years ago by
krushnach80690
krushnach80690 wrote:

I am trying to mine data or related paper from pubmed using R using library such as "RISmed" ,"rentrez" i will post the code so far what I have done

library(RISmed)
library(rentrez)
library(XML)
search_topic <- 'AML'
search_query <- EUtilsSummary(search_topic, retmax=100, mindate=2012, maxdate=2012)
QueryId(search_query)
your.ids <- c("23271436","23271044","23270581","23270192","23269287")

So upto now it looks fine so my Queryid function returns me a list of article ID so I want to parse those id for abstracts ,so the ID returned is kind of large number so is there anyway so that I dont have to copy paste the ID that is returned back from QueryID function and I want to use that returned ID in the later code which is this

fetch.pubmed <- entrez_fetch(db = "pubmed", id = your.ids,
                         rettype = "xml", parsed = T)

So can anyone help me I'm not sure if i can use the paste function or there is something else inbuilt in R.

Help would be highly appreciated

R • 1.4k views
ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by krushnach80690

I am not sure I understand the problem. Is it that you don't know how to deal with many IDs ? How about using a for loop or one of the apply functions ?
Note that in R, the paste() function is used to concatenate strings.

ADD REPLYlink written 3.3 years ago by Jean-Karim Heriche22k

well I managed to use the print and paste function to make it work i'm getting my desired output but I would like to know how to put that thing in for loop,can you let me know ?

ADD REPLYlink written 3.3 years ago by krushnach80690

I still don't understand the problem. I just realized that entrez_fetch() takes a list of IDs in the id parameter and returns the records in xml with rettype = "xml" so there's no need for a loop. Is the problem that you don't know how to form that list of IDs ? If so the solution should simply be

your.ids <- QueryId(search_query)
ADD REPLYlink written 3.3 years ago by Jean-Karim Heriche22k

well my problem is kind of solved but I will learn how to put the stuff into for loop

ADD REPLYlink written 3.3 years ago by krushnach80690
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1187 users visited in the last hour