Learn R Programming

gghinton (version 0.1.0)

as_hinton_df: Convert an object to a tidy data frame for geom_hinton()

Description

Generic function that dispatches to a method appropriate for x. Built-in methods exist for matrix, data.frame, and table.

Usage

as_hinton_df(x, ...)

# S3 method for matrix as_hinton_df(x, ...)

# S3 method for data.frame as_hinton_df( x, rowname_col = "row", colname_col = "col", value_col = "weight", ... )

# S3 method for table as_hinton_df(x, ...)

# S3 method for default as_hinton_df(x, ...)

Value

A data frame suitable for use with geom_hinton().

Arguments

x

An object to convert.

...

Additional arguments passed to the method.

rowname_col

Name of the column that holds the row index. Default "row".

colname_col

Name of the column that holds the column index. Default "col".

value_col

Name of the column that holds the matrix values. Default "weight".

Examples

Run this code
m <- matrix(c(1, -2, 3, -4), 2, 2)
as_hinton_df(m)

t <- table(c("a","b","a"), c("x","y","x"))
as_hinton_df(t)

Run the code above in your browser using DataLab