Learn R Programming

matRiks (version 0.1.3)

replace: Replace figures (Method)

Description

Replace a figure with another figure

Usage

replace(obj, index, replacement, visible)

# S3 method for figure replace(obj, index, replacement, visible = FALSE)

Value

An object with a changed figure

The starting object with a replaced figure

An object with a changed figure

The starting object with a replaced figure

Arguments

obj

A figure composed of different figures

index

integer, the index of the element to replace

replacement

The figure with which the original one is replaced

visible

logical, if TRUE it will replace only the visible figure. Default is FALSE

Methods (by class)

  • replace(figure): Replace figures

    Replace a figure with another figure

Examples

Run this code
# concanate three figures into an object
my_shapes <- cof(square(), triangle(), slice())
# draw object
draw(my_shapes)
# replace the square with a gray pacman
draw(replace(my_shapes, 1, pacman(shd = "grey")))
# concanate three figures into an object
my_shapes <- cof(square(), triangle(), slice())
# draw object
draw(my_shapes)
# replace the square with a gray pacman
draw(replace(my_shapes, 1, pacman(shd = "grey")))

Run the code above in your browser using DataLab