Learn R Programming

reutils (version 0.1.1)

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

Description

There are four ways to access data returned by an Entrez request: as a character string (as = "text"), as a textConnection (as = "textConnection"), as a parsed XML tree (as = "xml"), or, if supported, 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, ...)

content(x, as = "xml", ...)

## S3 method for class 'eutil': content(x, as = "xml", ...)

Arguments

x
An eutil object.
as
Type of output: "xml", "text", "textConnection", or "parsed".
...
Further arguments passed on to methods.

See Also

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

Examples

Run this code
e <- einfo()

## return XML as an 'XMLInternalDocument'.
content(e, "xml")

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

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


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

Run the code above in your browser using DataLab