Learn R Programming

teal.reporter (version 0.4.0)

PictureBlock: PictureBlock

Description

Specialized FileBlock for managing picture content in reports. It's designed to handle plots from packages such as ggplot2, grid, or lattice. It can save plots to files, set titles and specify dimensions.

Arguments

Super classes

teal.reporter::ContentBlock -> teal.reporter::FileBlock -> PictureBlock

Methods

Inherited methods


Method new()

Initialize a PictureBlock object.

Usage

PictureBlock$new(plot)

Arguments

plot

(ggplot or grid) a picture in this PictureBlock

Returns

Object of class PictureBlock, invisibly.


Method set_content()

Sets the content of this PictureBlock.

Usage

PictureBlock$set_content(content)

Arguments

content

(ggplot or grob or trellis) a picture in this PictureBlock

Details

Raises error if argument is not a ggplot, grob or trellis plot.

Returns

self, invisibly.


Method set_title()

Sets the title of this PictureBlock.

Usage

PictureBlock$set_title(title)

Arguments

title

(character(1)) a string assigned to this PictureBlock

Details

Raises error if argument is not character(1).

Returns

self, invisibly.

Examples

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_title("Title")


Method get_title()

Get the title of this PictureBlock.

Usage

PictureBlock$get_title()

Returns

The content of this PictureBlock.

Examples

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$get_title()


Method set_dim()

Sets the dimensions of this PictureBlock.

Usage

PictureBlock$set_dim(dim)

Arguments

dim

(numeric(2)) figure dimensions (width and height) in pixels.

Returns

self, invisibly.

Examples

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_dim(c(800, 600))


Method get_dim()

Get PictureBlock dimensions as a numeric vector.

Usage

PictureBlock$get_dim()

Returns

numeric the array of 2 numeric values representing width and height in pixels.

Examples

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$get_dim()


Method clone()

The objects of this class are cloneable with this method.

Usage

PictureBlock$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
library(ggplot2)
library(lattice)

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_content(ggplot(iris))

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_content(bwplot(1))

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_content(ggplotGrob(ggplot(iris)))

## ------------------------------------------------
## Method `PictureBlock$set_title`
## ------------------------------------------------

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_title("Title")


## ------------------------------------------------
## Method `PictureBlock$get_title`
## ------------------------------------------------

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$get_title()


## ------------------------------------------------
## Method `PictureBlock$set_dim`
## ------------------------------------------------

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$set_dim(c(800, 600))


## ------------------------------------------------
## Method `PictureBlock$get_dim`
## ------------------------------------------------

PictureBlock <- getFromNamespace("PictureBlock", "teal.reporter")
block <- PictureBlock$new()
block$get_dim()

Run the code above in your browser using DataLab