Title: | Serializable Representations |
Version: | 1.1.7 |
Maintainer: | Philipp Angerer <phil.angerer@gmail.com> |
Description: | String and binary representations of objects for several formats / mime types. |
URL: | https://github.com/IRkernel/repr/ |
BugReports: | https://github.com/IRkernel/repr/issues/ |
Depends: | R (≥ 3.0.1) |
Imports: | utils, grDevices, htmltools, jsonlite, pillar (≥ 1.4.0), base64enc |
Suggests: | methods, highr, Cairo, stringr, testthat (≥ 3.0.0), leaflet |
Enhances: | data.table, tibble, htmlwidgets, vegalite, plotly, geojsonio |
Config/testthat/edition: | 3 |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
Collate: | 'generics.r' 'options.r' 'package.r' 'repr_datatable.r' 'repr_datetime.r' 'utils.r' 'repr_list.r' 'repr_vector.r' 'repr_factor.r' 'repr_function.r' 'repr_help_files_with_topic.r' 'repr_htmlwidget.r' 'repr_matrix_df.r' 'repr_packageIQR.r' 'repr_plotly.r' 'repr_recordedplot.r' 'repr_spatial.r' 'repr_ts.r' 'repr_vega.r' 'zzz_onload.r' |
RoxygenNote: | 7.3.1 |
NeedsCompilation: | no |
Packaged: | 2024-03-22 09:08:06 UTC; phil |
Author: | Philipp Angerer |
Repository: | CRAN |
Date/Publication: | 2024-03-22 09:30:02 UTC |
The repr package
Description
String and binary representations of objects for several formats / mime types.
Details
The LaTeX repr of vectors needs \usepackage[inline]{enumitem}
The LaTeX repr of functions with the repr.function.highlight
option set to FALSE needs \usepackage{minted}
Author(s)
Maintainer: Philipp Angerer phil.angerer@gmail.com (ORCID)
Authors:
Thomas Kluyver thomas@kluyver.me.uk
Jan Schulz jasc@gmx.net
Other contributors:
abielr [contributor]
Denilson Figueiredo de Sa [contributor]
Jim Hester [contributor]
karldw [contributor]
Dave Foster [contributor]
Carson Sievert [contributor]
See Also
repr, repr-options, repr-generics, repr_text
Lists mapping mime types (mime2repr
) or format names (format2repr
) to repr
functions
Description
Lists mapping mime types (mime2repr
) or format names (format2repr
) to repr
functions
Usage
mime2repr
format2repr
Format
Lists mapping mime/name to function
An object of class list
of length 18.
Examples
names(mime2repr)
names(format2repr)
Dynamic representation
Description
Specify an object and a format to represent it in. Will stop()
if no such format is known.
Usage
repr(obj, format = "text", ...)
Arguments
obj |
The object to create a representation for |
format |
The representation format. |
... |
delegated to the specific |
Value
A character or raw vector of that format or NULL if none is defined.
Only the 'text'
format is defined for everything (via print()
)
See Also
Representations for specific formats
Description
Representations for specific formats
Usage
repr_html(obj, ...)
## Default S3 method:
repr_html(obj, ...)
repr_markdown(obj, ...)
## Default S3 method:
repr_markdown(obj, ...)
repr_latex(obj, ...)
## Default S3 method:
repr_latex(obj, ...)
repr_json(obj, ...)
## Default S3 method:
repr_json(obj, ...)
repr_javascript(obj, ...)
## Default S3 method:
repr_javascript(obj, ...)
repr_pdf(obj, ...)
## Default S3 method:
repr_pdf(obj, ...)
repr_png(obj, ...)
## Default S3 method:
repr_png(obj, ...)
repr_jpg(obj, ...)
## Default S3 method:
repr_jpg(obj, ...)
repr_svg(obj, ...)
## Default S3 method:
repr_svg(obj, ...)
repr_geojson(obj, ...)
## Default S3 method:
repr_geojson(obj, ...)
repr_vdom1(obj, ...)
## Default S3 method:
repr_vdom1(obj, ...)
repr_plotly1(obj, ...)
## Default S3 method:
repr_plotly1(obj, ...)
repr_vegalite2(obj, ...)
## Default S3 method:
repr_vegalite2(obj, ...)
repr_vegalite3(obj, ...)
## Default S3 method:
repr_vegalite3(obj, ...)
repr_vegalite4(obj, ...)
## Default S3 method:
repr_vegalite4(obj, ...)
repr_vega4(obj, ...)
## Default S3 method:
repr_vega4(obj, ...)
repr_vega5(obj, ...)
## Default S3 method:
repr_vega5(obj, ...)
Arguments
obj |
The object to create a repr for |
... |
parameters of the specific |
See Also
repr_text for the only repr that is always defined
repr options
Description
These options are used to control the behavior of repr when not calling it directly. Use options(repr.* = ...)
and getOption('repr.*')
to set and get them, respectively.
Usage
repr_option_defaults
Format
An object of class list
of length 15.
Details
Once this package is loaded, all options are set to defaults which weren’t set beforehand.
Setting all options set to NULL
are reset to defaults when reloading the package (or calling repr:::.onload()
).
Options
repr.plot.*
-
Those are for representations of
recordedplot
instances:repr.plot.width
Plotting area width in inches (default: 7)
repr.plot.height
Plotting area height in inches (default: 7)
repr.plot.pointsize
Text height in pt (default: 12)
repr.plot.bg
Background color (default: white)
repr.plot.antialias
Which kind of antialiasing to use for for lines and text? 'gray', 'subpixel' or 'none'? (default: gray)
repr.plot.res
PPI for rasterization (default: 120)
repr.plot.quality
Quality of JPEG format in % (default: 90)
repr.plot.family
Vector font family. 'sans', 'serif', 'mono' or a specific one (default: sans)
repr.vector.quote
-
Output quotation marks for character vectors? (default: TRUE)
repr.vector.max.items
-
How many items to display at max. Will insert an item with a horizontal ellipsis to show elision. (default: 400)
repr.matrix.max.rows
-
How many rows to display at max. Will insert a row with vertical ellipses to show elision. (default: 60)
repr.matrix.max.cols
-
How many cols to display at max. Will insert a column with horizontal ellipses to show elision. (default: 20)
repr.matrix.latex.colspec
-
How to layout LaTeX tables when representing matrices or data.frames. List of
row.head
, othercol
, andend
strings.end
mainly exists for when you want a vertical line there (default: 'r|', 'l', and ”) repr.function.highlight
-
Use the
highr
package to insert highlighting instructions into the code? Needs that package to be installed. (default: FALSE) repr.html.deduplicate
-
Use the html_dependencies manager to only include dependencies once? This can greatly reduce notebook size, but fails if e.g. iframes are used (default: FALSE)
Representation of data.table objects
Description
Representation of data.table objects
Usage
## S3 method for class 'data.table'
repr_html(obj, ...)
## S3 method for class 'data.table'
repr_text(obj, ...)
## S3 method for class 'data.table'
repr_latex(obj, ...)
Arguments
obj |
The list to create a representation for |
... |
ignored |
Representations of factors
Description
Representations of factors
Usage
## S3 method for class 'factor'
repr_html(obj, ...)
## S3 method for class 'factor'
repr_markdown(obj, ...)
## S3 method for class 'factor'
repr_latex(obj, ...)
Arguments
obj |
The factor to create a representation for |
... |
ignored |
Representations of functions
Description
Representations of functions
Usage
## S3 method for class ''function''
repr_html(obj, highlight = getOption("repr.function.highlight"), ...)
## S3 method for class ''function''
repr_latex(obj, highlight = getOption("repr.function.highlight"), ...)
## S3 method for class ''function''
repr_markdown(obj, fenced = TRUE, ...)
Arguments
obj |
Function to create a representation for |
highlight |
Should code highlighting be performed |
... |
ignored |
fenced |
Should a fenced code block instead of an indented one be used? |
Representations of help
Description
Representations of help
Usage
## S3 method for class 'help_files_with_topic'
repr_text(obj, ...)
## S3 method for class 'help_files_with_topic'
repr_html(obj, ...)
## S3 method for class 'help_files_with_topic'
repr_latex(obj, ...)
Arguments
obj |
Help topic to create a representation for |
... |
ignored |
HTML widget representations
Description
Standalone HTML representation and dummy text representation.
Usage
html_dependencies
## S3 method for class 'htmlwidget'
repr_text(obj, ...)
## S3 method for class 'htmlwidget'
repr_html(obj, ...)
## S3 method for class 'shiny.tag'
repr_text(obj, ...)
## S3 method for class 'shiny.tag'
repr_html(obj, ...)
## S3 method for class 'shiny.tag.list'
repr_text(obj, ...)
## S3 method for class 'shiny.tag.list'
repr_html(obj, ...)
Arguments
obj |
The htmlwidget, shiny.tag, or shiny.tag.list to create a representation for |
... |
ignored |
Format
An object of class environment
of length 4.
Details
html_dependencies
is an environment containing the following functions.
getOption('repr.html.deduplicate')
get()
Get the list of added dependencies
add(dep)
Marks a dependency as added. Call this e.g. after appending a script tag with the dependency.
clear()
Clear the list as seen dependencies. Now everything will be added again when encountered.
dir()
Returns the directory in which the dependencies reside.
Representations of lists
Description
Representations of lists
Usage
## S3 method for class 'list'
repr_html(obj, ...)
## S3 method for class 'list'
repr_markdown(obj, ...)
## S3 method for class 'list'
repr_latex(obj, ...)
Arguments
obj |
The list to create a representation for |
... |
ignored |
Tabular data representations
Description
HTML, LaTeX, and Markdown representations of Matrix-like objects
Usage
## S3 method for class 'matrix'
repr_html(
obj,
...,
rows = getOption("repr.matrix.max.rows"),
cols = getOption("repr.matrix.max.cols")
)
## S3 method for class 'data.frame'
repr_html(
obj,
...,
rows = getOption("repr.matrix.max.rows"),
cols = getOption("repr.matrix.max.cols")
)
## S3 method for class 'matrix'
repr_latex(
obj,
...,
rows = getOption("repr.matrix.max.rows"),
cols = getOption("repr.matrix.max.cols"),
colspec = getOption("repr.matrix.latex.colspec")
)
## S3 method for class 'data.frame'
repr_latex(
obj,
...,
rows = getOption("repr.matrix.max.rows"),
cols = getOption("repr.matrix.max.cols"),
colspec = getOption("repr.matrix.latex.colspec")
)
## S3 method for class 'matrix'
repr_markdown(
obj,
...,
rows = getOption("repr.matrix.max.rows"),
cols = getOption("repr.matrix.max.cols")
)
## S3 method for class 'data.frame'
repr_markdown(
obj,
...,
rows = getOption("repr.matrix.max.rows"),
cols = getOption("repr.matrix.max.cols")
)
## S3 method for class 'matrix'
repr_text(
obj,
...,
rows = getOption("repr.matrix.max.rows"),
cols = getOption("repr.matrix.max.cols")
)
## S3 method for class 'data.frame'
repr_text(
obj,
...,
rows = getOption("repr.matrix.max.rows"),
cols = getOption("repr.matrix.max.cols")
)
Arguments
obj |
The matrix or data.frame to create a representation for |
... |
ignored |
rows |
The maximum number of rows displayed. The default is given by the option |
cols |
The maximum number of columns displayed. The default is given by the option |
colspec |
The colspec for the LaTeX table. The default is given by the option |
See Also
repr-options for repr.matrix.latex.colspec
packageIQR representations
Description
Text representations of packageIQR objects like the list of available example data or vignettes
Usage
## S3 method for class 'packageIQR'
repr_text(obj, ...)
## S3 method for class 'packageIQR'
repr_html(obj, ...)
Arguments
obj |
The packageIQR obj to create a representation for |
... |
ignored |
Examples
repr_html(data(package = 'datasets'))
repr_text(vignette(package = 'highr'))
Plot representations
Description
repr_text.recordedplot
only returns a small info string containing the title (if any)
while the others return a character vector (SVG) or a raw vector (the rest) containing the image data.
Usage
## S3 method for class 'recordedplot'
repr_text(obj, ...)
## S3 method for class 'recordedplot'
repr_png(
obj,
width = getOption("repr.plot.width"),
height = getOption("repr.plot.height"),
bg = getOption("repr.plot.bg"),
pointsize = getOption("repr.plot.pointsize"),
antialias = getOption("repr.plot.antialias"),
res = getOption("repr.plot.res"),
...
)
## S3 method for class 'recordedplot'
repr_jpg(
obj,
width = getOption("repr.plot.width"),
height = getOption("repr.plot.height"),
bg = getOption("repr.plot.bg"),
pointsize = getOption("repr.plot.pointsize"),
antialias = getOption("repr.plot.antialias"),
res = getOption("repr.plot.res"),
quality = getOption("repr.plot.quality"),
...
)
## S3 method for class 'recordedplot'
repr_svg(
obj,
width = getOption("repr.plot.width"),
height = getOption("repr.plot.height"),
bg = getOption("repr.plot.bg"),
pointsize = getOption("repr.plot.pointsize"),
antialias = getOption("repr.plot.antialias"),
family = getOption("repr.plot.family"),
...
)
## S3 method for class 'recordedplot'
repr_pdf(
obj,
width = getOption("repr.plot.width"),
height = getOption("repr.plot.height"),
bg = getOption("repr.plot.bg"),
pointsize = getOption("repr.plot.pointsize"),
antialias = getOption("repr.plot.antialias"),
family = getOption("repr.plot.family"),
...
)
Arguments
obj |
The plot to create a representation for |
... |
ignored |
width |
Plot area width in inches (default: 7) |
height |
Plot area height in inches (default: 7) |
bg |
Background color (default: white) |
pointsize |
Text height in pt (default: 12) |
antialias |
Which kind of antialiasing to use for for lines and text? 'gray', 'subpixel' or 'none'? (default: gray) |
res |
For PNG and JPEG, specifies the PPI for rasterization (default: 120) |
quality |
For JPEG, determines the compression quality in % (default: 90) |
family |
Font family for SVG and PDF. 'sans', 'serif', 'mono' or a specific one (default: sans) |
Details
All parameters can also be specified using the eponymous repr.plot.*
repr-options.
Examples
dev.new()
dev.control(displaylist = 'enable')
plot(sqrt, main = 'Square root')
p <- recordPlot()
dev.off()
repr_text(p)
Time series representations
Description
HTML, LaTeX, and Markdown representations of ts objects.
Usage
## S3 method for class 'ts'
repr_html(obj, ...)
## S3 method for class 'ts'
repr_latex(obj, ..., colspec = getOption("repr.matrix.latex.colspec"))
## S3 method for class 'ts'
repr_markdown(obj, ...)
## S3 method for class 'ts'
repr_text(obj, ...)
Arguments
obj |
The ts object to create a representation for |
... |
ignored |
colspec |
The colspec for the LaTeX table. The default is given by the option |
See Also
repr-options for repr.matrix.latex.colspec
Representations of vectors
Description
Representations of vectors
Usage
## S3 method for class 'logical'
repr_html(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'integer'
repr_html(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'complex'
repr_html(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'numeric'
repr_html(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'character'
repr_html(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'Date'
repr_html(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'logical'
repr_markdown(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'integer'
repr_markdown(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'complex'
repr_markdown(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'numeric'
repr_markdown(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'character'
repr_markdown(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'Date'
repr_markdown(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'logical'
repr_latex(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'integer'
repr_latex(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'complex'
repr_latex(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'numeric'
repr_latex(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'character'
repr_latex(obj, ..., items = getOption("repr.vector.max.items"))
## S3 method for class 'Date'
repr_latex(obj, ..., items = getOption("repr.vector.max.items"))
Arguments
obj |
The vector to create a representation for |
... |
ignored |
items |
The maximum number of items displayed. The default is given by the option |
Representations of spatial objects: See geojson_list for supported classes.
Description
Representations of spatial objects: See geojson_list for supported classes.
Usage
## S3 method for class 'geo_list'
repr_geojson(obj, ...)
## S3 method for class 'SpatialCollections'
repr_geojson(obj, ...)
## S3 method for class 'SpatialPolygons'
repr_geojson(obj, ...)
## S3 method for class 'SpatialPolygons'
repr_geojson(obj, ...)
## S3 method for class 'SpatialPolygonsDataFrame'
repr_geojson(obj, ...)
## S3 method for class 'SpatialPoints'
repr_geojson(obj, ...)
## S3 method for class 'SpatialPointsDataFrame'
repr_geojson(obj, ...)
## S3 method for class 'SpatialLines'
repr_geojson(obj, ...)
## S3 method for class 'SpatialLinesDataFrame'
repr_geojson(obj, ...)
## S3 method for class 'SpatialGrid'
repr_geojson(obj, ...)
## S3 method for class 'SpatialGridDataFrame'
repr_geojson(obj, ...)
## S3 method for class 'SpatialPixels'
repr_geojson(obj, ...)
## S3 method for class 'SpatialPixelsDataFrame'
repr_geojson(obj, ...)
## S3 method for class 'SpatialRings'
repr_geojson(obj, ...)
## S3 method for class 'SpatialRingsDataFrame'
repr_geojson(obj, ...)
## S3 method for class 'sf'
repr_geojson(obj, ...)
## S3 method for class 'sfg'
repr_geojson(obj, ...)
## S3 method for class 'sfc'
repr_geojson(obj, ...)
Arguments
obj |
The spatial object to create a representation for |
... |
ignored |
Representation as Plotly JSON.
Description
Representation as Plotly JSON.
Usage
## S3 method for class 'plotly'
repr_plotly1(obj, ...)
## S3 method for class 'ggplot'
repr_plotly1(obj, ...)
Arguments
obj |
|
... |
ignored |
Text representation
Description
The only representation defined per default for everthing (via print()
)
Usage
repr_text(obj, ...)
## Default S3 method:
repr_text(obj, ...)
Arguments
obj |
The object to print and then return the output |
... |
ignored |
See Also
repr-generics for other generics
Representation as vegalitev2
or vega4
JSON.
Description
Representation as vegalitev2
or vega4
JSON.
Usage
## S3 method for class 'vegalite'
repr_vegalite2(obj, ...)
Arguments
obj |
The vegalite plot to create a representation for |
... |
ignored |