R: A reference class for generating transition plots
Transition-class
R Documentation
A reference class for generating transition plots
Description
This class simplifies the creating of transition plots. It also
allows for advanced multi-column transitions.
Fields
transitions
This is a >= 3 dimensional array with the transitions. Should not be direcly accessed.
box_width
The box width
box_txt
The texts of each box
box_label
Box labels
box_label_pos
The label's positions, either "top"/"bottom"
box_label_cex
The size of the box labels
box_cex
The fontsize multiplier for the text within the boxes
arrow_type
The type of arrow to use, defaults to "gradient", but can also be "simple".
The corresponding functions are bezierArrowGradient, and
bezierArrowSmpl. Note The bezierGrob ("grid") has been deprecated
as it is no longer faster than the bezierArrows and there is a difference in design.
arrow_clr
The arrow color
arrow_rez
The rezolution of the arrow
vertical_space
The space between the boxes
fill_clr
The box fill color
clr_bar
Shows a color bar if there are proportions. Can be "none", "top", "bottom"
clr_bar_clrs
Extracts the colors for the colorbar from the fill_clr if none is provided
clr_bar_cex
The size of the ticks in the color bar
clr_bar_subspace
If there is little or no difference exists at the low/high proportions of
the spectrum then it can be of interest to focus the color change to the center leaving the tails constant
clr_bar_labels
The labels of the color bars. Defaults to the dimnames for the proportions.
txt_clr
The text color within the boxes
title
The plot title if any
title_cex
The fontsize multiplier for the title
mar
The margins for the plot.
min_lwd
The minimum line width that is still shown. The pixels will most likely
not have the same fine resolution as the data and you therefore may want to hide
lines that are smaller than a certain amount.
max_lwd
The maximum line width to show
lwd_prop_type
The line can either be proportional to the "set" of transitions
(group of two box columns), to "all" transitions, or to each "box". It defaults
to "all".
data
Internal storage variable. Should not be accessed directly.
Methods
addClr(fill, txt)
Adds colors or extends existing one so that they match the transition matrix.
The fill corresponds to the fill_clr and txt corresponds to the txt_clr. If
the colors are missing and the transitions consist of only two columns the default
colors will be used. If the matrix is being extended and these values are missing the
values from the previous last column will be used for the default columns.
Add a transition matrix. The input has to be a numerical matrix between 2 and 3 dimensions.
If you don't provide the txt field the box' text field will be deduced from the transition matrix'
dimnames. The fill_clr and txt_clr are passed on to the addClr function.
arrowWidths(set_no, add_width)
Retreives the details regarding arrow sizes for each arrow within the transition
group
boxPositions(col)
The box positions as a list with scalars for the positions:
x The center x-position
y The center y-position
right The right edge
left The left edge
top The top edge
bottom The bottom edge
height The box height
width The box width
unit The unit used for the values (npc)
boxSizes(col)
Gets the size of the boxes. The col argumente shoud
is either an integer or 'last'
getDim()
Gets the current dimensions of the transitions
getTransitionSet(no, reduce_dim = FALSE)
Gets a specific set of transitions. If the reduce_dim is set
to TRUE it will only return a 2-dimensional matrix even if the original
has a 3rd proportions dimension
getYProps(col)
Gets the proportions after removing the vertical_space
between the boxes
Set up a Transition object. The transitions should be a 2D or 3D matrix
as defined in the $addTransitions section and not as later internally stored.
noCols()
Gets the number of columns, i.e. the number of transitions
noRows(no)
Gets the number of boxes in each row.
If multiple rows the number of rows may differ
betwen each transition matrix we therefore need
to specify what transitions that we refer to.
If no value is specified it returns all of them.
render(new_page = TRUE)
Call this to render the full graph. The new_page argument
is for creating a new plot, set this to FALSE
if you want to combine this plot with another or if you have
additional viewports that you intend to use.
trnstnSizes(set_no)
Gets the transitions per box as a 2D matrix. For the proportions
it also adds an attribute attr('props', prop_mtrx) that
is a 2D matrix with the corresponding proportions.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Gmisc)
Loading required package: Rcpp
Loading required package: htmlTable
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Gmisc/Transition-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Transition-class
> ### Title: A reference class for generating transition plots
> ### Aliases: Transition Transition-class
>
> ### ** Examples
>
> # Transitions
> set.seed(1)
> n <- 10
> my_data <-
+ data.frame(
+ Var_a = sample(c("Test 1",
+ "Test 2",
+ "Test 3"),
+ size = n,
+ replace = TRUE,
+ prob = 3:1),
+ Var_b = sample(c("Test 1",
+ "Test 2",
+ "Test 3"),
+ size = n,
+ replace = TRUE,
+ prob = 1:3))
> mtrx <- with(my_data,
+ table(Var_a, Var_b))
>
> # Initialize the transition plot
> transitions <-
+ getRefClass("Transition")$new(mtrx, label=c("Before", "After"))
>
> # Render the plot
> transitions$render()
>
>
>
>
>
> dev.off()
null device
1
>