This function is used to create a scatter plot of model estimates against clade age. Requires package 'ggplot2'

plot_est_age(
  data,
  X,
  Y,
  Group = NULL,
  abs.value = FALSE,
  var = NULL,
  Title = NULL,
  palette = NULL,
  shapes = NULL,
  fill = NULL,
  plot_theme = NULL
)

Arguments

data

A data frame holding at least the beta estimates and age for each clade.

X

A character equal to the name of the column in data that holds the clade ages

Y

A character equal to the name of the column in data that holds the estimates

Group

Optional. A character equal to the name of the column in data that holds the groups.

abs.value

Logical. If TRUE, then the absolute value of the estimates is plotted.

var

Optional. A character equal to the name of the variable the beta estimates are for

Title

Optional. A character to be displayed as the plot's title

palette

Optional. A vector with length equal to the number of groups to be displayed. This vector is passed on to scale_color_manual() to dictate the color representation of each group

shapes

Optional. A list of length 2 with the first element holding a character equal to the name of the column in data that holds the groups. The second element should be a vector with length equal to the number of groups to be displayed. This vector is passed on to scale_shape_manual() to dictate the shape representation of each group

fill

Optional. A vector that holds the color(s) to fill the point shapes with

plot_theme

Optional. An object returned by the theme() function. See help(theme) for more details

Value

A scatter plot of estimates against clade ages in the form of a ggplot object

Examples

if (FALSE) {

library(here)
library(ggplot2)

ests <- read.csv(file.path(here(), 'data_out', 'Avg_Est_SR.csv'), header = TRUE)
ages <- read.csv(file.path(here(), 'data_out', 'Herp_Taxon_Ages.csv'), header = TRUE)
names(ages)[1] <- 'Taxon'

dat <- merge(ests, ages, by = 'Taxon', all.x = TRUE)
dat <- droplevels(dat[which(dat$Group == 'Total' | dat$Group == 'Native'), ])
tmp <- droplevels(dat[which(dat$Variable == 'Area'), ])

(plot_est_age(data = tmp,
              X = "Age",
              Y = "Estimate",
              Group = "Group",
              var = "Area",
              Title = "Effect of Area by Clade Age",
              palette = c("red3", "blue3"),
              shapes = list("Group", c(16, 23)),
              fill = 'white'))

}