plotPresBar: plotPresBar

View source: R/plotPresBar.R

plotPresBarR Documentation

plotPresBar

Description

Creates a bar plot of the presence or density of detections across time

Usage

plotPresBar(
  x,
  start = NULL,
  end = NULL,
  bin = "hour/day",
  by = NULL,
  title = TRUE,
  fill = "grey35",
  format = c("%m/%d/%Y %H:%M:%S", "%m-%d-%Y %H:%M:%S",
    "%Y/%m/%d %H:%M:%S", "%Y-%m-%d %H:%M:%S"),
  plotTz = "UTC"
)

Arguments

x

a data.frame of detections, must have a column UTC that contains the time of detection as a POSIXct object in UTC timezone

start

the beginning datetime of the plot, if NULL will be set to the minimum time in x

end

the ending datetime of the plot, if NULL will be set to the maximum time in x

bin

string identifying how to bin detections. Acceptable time units are c('minute', 'hour', 'day', 'week', 'month'). For presence, bin should be of the form 'unit1/unit2', e.g. 'hour/day' will show the hours per day with detections. For call density, bin is a single time unit, e.g. 'hour' will show the number of calls per hour. Call density can also be specified as 'call/hour'. Note that plural forms of all units are accepted.

by

(optional) if not NULL, specifies the name of a column in x to split and color the bars by

title

if TRUE, a title will automatically created. If any other value, that will be used for the title of the plot.

fill

the fill color for the bars, only used if by is NULL, otherwise bars are colored by species using the default ggplot2 palette

format

date format if UTC column of x is a character

plotTz

the timezone to use for plotting the data. Note that inputs must still be in UTC, this option allows you to create plots scaled to local time. Valid values come from OlsonNames

Value

a ggplot2 object

Author(s)

Taiki Sakai taiki.sakai@noaa.gov

Examples


df <- data.frame(UTC = as.POSIXct(runif(1e2, min=0, max=7*24*3600),
                                  origin='1970-01-01 00:00:00', tz='UTC'),
                 label = sample(letters[1:3], 1e2, replace=TRUE))
# hours per day with detections
plotPresBar(df, bin='hour/day')
# calls per day - these options are identical
plotPresBar(df, bin='day')
plotPresBar(df, bin='call/day')
plotPresBar(df, bin='calls/day')
# calls per day, colored by 'label'
plotPresBar(df, bin='day', by='label')


PAMmisc documentation built on June 22, 2024, 9:37 a.m.