install.packages(RISmed)
library(RISmed)
res <- EUtilsSummary("PTEN", type="esearch", db="pubmed", retmax=500)
EUtilsGet(res,type="efetch",db="pubmed")
QueryCount(res) # No. of results returned
summary(res) # Summary of your query
y <- YearPubmed(EUtilsGet(res)) # Year of publication
t<-ArticleTitle(EUtilsGet(res)) # Title
a <-AbstractText(EUtilsGet(res)) # Abstract
at <- Author(EUtilsGet(res))
at1 <-lapply(at, `[[`, 1) # Extract the first row of each list because I only need the 1st author
at_first<-lapply(at1, `[[`, 1) # Extract the first element of each row
at_first_row <- as.data.frame(at_first) # Format as dataframe
at_first_column <- t(at_first_row) # Convert row to column using transpose t()
myresults <- data.frame('1stAuthor'= at_first_column,'year' = y, 'Title'=t,'Abstract'=a)
write.csv(myresults, file = "pubmed_literature.csv",row.names = FALSE)