R/removeabs.R

setGeneric("removeabs", function(object,x,y) standardGeneric("removeabs"));
setMethod("removeabs","Abstracts",function(object,x,y){tempabs <- object@Abstract; tempuids <- object@PMID; tempjournal <- object@Journal; xj<- regexpr(x,tempabs,ignore.case = y); xxj<- 0;xxj<- c(xxj,which(xj == -1)); newtempuids <- NULL; newtempabs <- NULL; newtempjournal <- NULL;
  for(m in seq(along = xxj)) {if(xxj[m] > 0 ) {tempm <- xxj[m];newtempuids<- c(newtempuids,tempuids[tempm]); newtempabs <-c(newtempabs,tempabs[tempm]); newtempjournal <- c(newtempjournal,tempjournal[tempm]) }}; 
	if ( length(xxj) == 1 ) {print(paste("No abstracts found for the term",x,sep =" "));write(paste("No abstracts found for the term",x,sep =" "), file = "dataout.txt", append = T);result <- new("Abstracts", Journal = "NONE", Abstract = "NONE", PMID = 0); return(result)} else {result <- new("Abstracts", Journal = newtempjournal, Abstract = newtempabs, PMID = newtempuids); print(paste( (length(tempuids) - length(result@PMID)),"abstracts","removed abstracts for term",x,sep = " ")); write(paste( (length(tempuids) - length(result@PMID)),"abstracts","removed abstracts for term",x,sep = " "), file = "dataout.txt", append = T); return(result)}  })

Try the pubmed.mineR package in your browser

Any scripts or data that you put into this service are public.

pubmed.mineR documentation built on Nov. 26, 2021, 5:11 p.m.