Please help in easyPubMed coding error.

Hi,

I am trying to extract data via easyPubmed package and it shows me total 7038 subjects. However, when I run the code for rows it shows me in 400 and when I try to export in excel, it only gives me 400 subjects not 7038. I have shared my code here, please help me I have assignment due soon.

Thanks,

library(easyPubMed)
qr1 <- get_pubmed_ids("Nephrology Randomized Controlled Trial AND 2000 : 2021[PDAT]")
print(qr1$Count)
data1 <- fetch_pubmed_data(qr1)
df1 <- table_articles_byAuth(data1, included_authors = 'last',
autofill = TRUE, max_chars = -1)

nrow(df1)
library(writexl)
write_xlsx(df1, path = "excel_1.xlsx")

from help(fetch_pubmed_data)

fetch_pubmed_data(pubmed_id_list, 
                         retstart = 0, 
                         retmax = 500, 
                         format = "xml", 
                         encoding = "UTF8")

retmax Integer (>=1): size of the batch of PubMed records to be retrieved at one time.

for batches of up to 5000 records.

This should work

out1 <- batch_pubmed_download(pubmed_query_string = query, batch_size = 500)

library(easyPubMed)
qr1 <- get_pubmed_ids ("Nephrology Randomized Controlled Trial AND 2000 : 2021[PDAT]")
print(qr1$Count)
df1<- get_pubmed_ids(qr1)
data1 <- fetch_pubmed_data(qr1)

data1 <- fetch_pubmed_data(qr1)
df1 <- table_articles_byAuth(data1, included_authors = 'last',
autofill = TRUE, max_chars = -1)

nrow(df1)
keep_cols <- c('pmid', 'year','jabbrv', 'lastname')
df1 [,keep_cols]
batch_pubmed_download(pubmed_query_string, research = NULL,
dest_file_prefix = "easyPubMed_data_",
format = "xml", api_key = NULL,
batch_size = 5000, res_cn = 1,
encoding = "UTF8")

out1 <- batch_pubmed_download(data1 = query, batch_size = 5000) Even this doesn't work!!!

Why these doesn't work.
Trying to get following data and it is taking whole day even doesn't work. Please help.

library(easyPubMed)
qr1 <- get_pubmed_ids ("Nephrology Randomized Controlled Trial AND 2000 : 2021[PDAT]")
print(qr1$Count)

df1<- get_pubmed_ids(qr1)
data1 <- fetch_pubmed_data(qr1)
df1 <- table_articles_byAuth(data1, included_authors = 'last',
autofill = TRUE, max_chars = -1)

nrow(df1)
keep_cols <- c('pmid', 'year','jabbrv', 'lastname')
df1 [,keep_cols]

batch_pubmed_download(pubmed_query_string, research = NULL,
dest_file_prefix = "easyPubMed_data_",
format = "xml", api_key = NULL,
batch_size = 5000, res_cn = 1,
encoding = "UTF8")

out1 <- batch_pubmed_download(data1 = query, batch_size = 5000) Even this doesn't work!!!

  1. Get and set an API key; you might be getting throttled. From the easyPubMed documentation

The following code illustrates the use of the argument api_key , which was introduced in version 2.11. E-utils users are now limited to 3 requests/second if an API key is not provided. However, users can obtain an NCBI/Entrez API key to increase the e-utils limit to 10 requests/second. For more information, visit: (https://www.ncbi.nlm.nih.gov/account/settings/)[https://www.ncbi.nlm.nih.gov/account/settings/]. Two easyPubMed functions can accept an api_key argument: get_pubmed_ids() , and batch_pubmed_download() . Requests submitted by the latter function are automatically paced, therefore the use of a key may speed the queries if records are retrieved in small batches. Please, use your own API key, as the one provided in the vignette has been replaced and is no longer valid.

  1. In any event, test your code with a query that will return a short number of results, to make sure the logic works.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.