Each Media
subclass may be converted to/from one or more R
types. The mappings are established by setAs
.
The following bi-directional mappings are built into the package:
application/xml , text/html |
XMLAbstractNode |
application/json |
list |
text/csv |
data.frame |
But call mediaCoercionTable
to see what is defined in the
current session.
The as
function is the canonical interface to converting
media to R objects. It (usefully) requires that the user specify the
target R type. For convenience, the mediaTarget
generic
returns the default R type for a given Media
object.
To support a new media type, one should define a Media
subclass
with the same name as the media type (application/xml
), a
corresponding mediaTarget
method, and all relevant
coerce
methods. See the Media
class hierarchy to
determine where the new type fits.