Learn R Programming

Momocs (version 1.4.1)

plot_CV: Plots a cross-validation table as an heatmap

Description

Either with frequencies (or percentages) plus marginal sums, and values as heatmaps. Used in Momocs for plotting cross-validation tables but may be used for any table (likely with freq=FALSE).

Usage

plot_CV(
  x,
  freq = FALSE,
  rm0 = FALSE,
  pc = FALSE,
  fill = TRUE,
  labels = TRUE,
  axis.size = 10,
  axis.x.angle = 45,
  cell.size = 2.5,
  signif = 2,
  ...
)

# S3 method for default plot_CV( x, freq = FALSE, rm0 = FALSE, pc = FALSE, fill = TRUE, labels = TRUE, axis.size = 10, axis.x.angle = 45, cell.size = 2.5, signif = 2, ... )

# S3 method for LDA plot_CV( x, freq = TRUE, rm0 = TRUE, pc = TRUE, fill = TRUE, labels = TRUE, axis.size = 10, axis.x.angle = 45, cell.size = 2.5, signif = 2, ... )

Value

a ggplot object

Arguments

x

a (cross-validation table) or an LDA object

freq

logical whether to display frequencies (within an actual class) or counts

rm0

logical whether to remove zeros

pc

logical whether to multiply proportion by 100, ie display percentages

fill

logical whether to fill cell according to count/freq

labels

logical whether to add text labels on cells

axis.size

numeric to adjust axis labels

axis.x.angle

numeric to rotate x-axis labels

cell.size

numeric to adjust text labels on cells

signif

numeric to round frequencies using signif

...

useless here

See Also

LDA, plot.LDA, and (pretty much the same) plot_table.

Examples

Run this code
h <- hearts %>%
     fgProcrustes(0.01) %>% coo_slide(ldk=2) %T>% stack %>%
     efourier(6, norm=FALSE) %>% LDA(~aut)

h %>% plot_CV()
h %>% plot_CV(freq=FALSE, rm0=FALSE, fill=FALSE)
# you can customize the returned gg with some ggplot2 functions
h %>% plot_CV(labels=FALSE, fill=TRUE, axis.size=5) + ggplot2::ggtitle("A confusion matrix")

# or build your own using the prepared data_frame:
df <- h %>% plot_CV() %$% data
df

# you can even use it as a cross-table plotter
bot$fac %>% table %>% plot_CV()

Run the code above in your browser using DataLab