Learn R Programming

reutils (version 0.2.1)

content,ecitmatch-method: Extract the data content from an Entrez request

Description

There are five ways to access data returned by an Entrez request: as a character string (as = "text"), as a textConnection (as = "textConnection"), as an XMLInternalDocument (as = "xml") or json object (as = "json") (depending on the retmode with which the request was performed), or parsed into a native R object, e.g. a list or a data.frame (as = "parsed").

Usage

## S3 method for class 'ecitmatch':
content(x, as = "text")

## S3 method for class 'efetch': content(x, as = NULL)

## S3 method for class 'egquery': content(x, as = NULL)

## S3 method for class 'einfo': content(x, as = NULL)

## S3 method for class 'elink': content(x, as = NULL)

## S3 method for class 'epost': content(x, as = NULL)

## S3 method for class 'esearch': content(x, as = NULL)

## S3 method for class 'espell': content(x, as = NULL)

## S3 method for class 'esummary': content(x, as = NULL)

content(x, ...)

## S3 method for class 'eutil': content(x, ...)

Arguments

x
An eutil object.
as
Type of output: "text", "xml", "json", "textConnection", or "parsed". content attempts to figure out the most appropriate output type, based on the retmode of the o
...
Further arguments passed on to methods.

Methods (by class)

  • ecitmatch: Return PubMed IDs ifas = "parsed".
  • efetch:
  • egquery:
  • einfo:
  • elink:
  • epost:
  • esearch:
  • espell:
  • esummary:
  • eutil:

See Also

einfo, esearch, esummary, efetch, elink, epost, egquery, espell, ecitmatch.

Examples

Run this code
## einfo() defaults to retmode 'xml'
e <- einfo()

## automatically return data as an 'XMLInternalDocument'.
if (e$no_errors()) {
  content(e)

  ## return the XML data as character string.
  cat(content(e, "text"))

  ## return DbNames parsed into a character vector.
  content(e, "parsed")
}

## return data as a JSON object
e2 <- einfo(db = "gene", retmode = "json")
if (e2$no_errors()) {
  content(e2)
}

## return a textConnection to allow linewise reading of the data.
x <- efetch("CP000828", "nuccore", rettype = "gbwithparts", retmode = "text")
con <- content(x, as = "textConnection")
readLines(con, 2)
close(con)

Run the code above in your browser using DataLab