Pubmed Query using R
0
0
Entering edit mode
7.3 years ago
1769mkc ★ 1.2k

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 • 2.6k views
ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1830 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6