This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Pubmed Query using R

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

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.

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 ?

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)

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

0 answers

No answers yet.

Log in to answer this question.