plotObs: Creates a 'ggplot' object from an obs data frame

View source: R/plotObs.R

plotObsR Documentation

Creates a ggplot object from an obs data frame

Description

This function creates a ggplot2 object from an obs data frame. If the specified variables are all of single type (e.g. temperature), it returns a single-pane plot. If the specified variables are of more than one type (e.g. temperature, precipitation), then the plot is faceted. The function returns an object that you can modify, or save with the standard ggplot2 commands.

Usage

plotObs(obs, varcols = c(0), startDate = "", endDate = "", plotType = "lines")

Arguments

obs

Required. The CRHMr obs data frame to be plotted.

varcols

Optional. A vector containing the numbers of the columns (not including the datatime) to be plotted. If not specified, all variables are plotted.

startDate

Optional. The starting date for the plot. Can either be a year as a number (e.g. 1995) or a date in Y-m-d format, i.e. 1995-06-01. If not specified, the first datetime value in the obs data is used.

endDate

Optional. The ending date for the plot. Can either be a year as a number (e.g. 1995) or a date in Y-m-d format, i.e. 1995-12-31. If not specified, the first datetime value in the obs data is used.

plotType

Optional. Defines the type of the plot. Either lines or points. Default is lines. If you want to show the extent of data, use points as lines will NOT be drawn when points are separated by NA_real_ values.

Details

Units are automatically specified for obs variables of the following types: t, rh, u, p, ea, and solar radiation.

Value

If successful returns a ggplot2 object. If unsuccessful, returns the value FALSE.

Note

Note that missing (NA_real_) values in the obs data frame will result in a warning message.

Author(s)

Kevin Shook

See Also

summariseObsFiles

Examples

p <- plotObs(BadLake7376)
print(p)

CentreForHydrology/CRHMr documentation built on April 6, 2024, 5:27 p.m.