getPreciBar: get mean rainfall bar plot of the input dataset or time...

getPreciBarR Documentation

get mean rainfall bar plot of the input dataset or time series.

Description

get mean rainfall bar plot of the input dataset or time series.

Usage

getPreciBar(
  data,
  method,
  cell = "mean",
  output = "data",
  name = NULL,
  plotRange = TRUE,
  member = NULL,
  omitNA = TRUE,
  info = FALSE,
  ...
)

## S4 method for signature 'list'
getPreciBar(
  data,
  method,
  cell = "mean",
  output = "data",
  name = NULL,
  plotRange = TRUE,
  member = NULL,
  omitNA = TRUE,
  info = FALSE,
  ...
)

## S4 method for signature 'data.frame'
getPreciBar(
  data,
  method,
  cell = "mean",
  output = "data",
  name = NULL,
  plotRange = TRUE,
  member = NULL,
  omitNA = TRUE,
  info = FALSE,
  ...
)

Arguments

data

A list containing different information, should be the result of reading netcdf file using loadNcdf, or a time series, with first column the Date, second the value. Time series can be an ENSEMBLE containning different members. Than the mean value will be given and the range will be given.

method

A string showing the calculating method of the input time series. More information please refer to the details.

cell

A vector containing the locaton of the cell, e.g. c(2, 3), default is "mean", representing the spatially averaged value. Check details for more information.

output

A string showing the type of the output, if output = 'ggplot', the returned data can be used in ggplot and getPreciBar_comb(); if output = 'plot', the returned data is the plot containing all layers' information, and can be plot directly or used in grid.arrange; if not set, the data will be returned.

name

If output = 'ggplot', name has to be assigned to your output, in order to differentiate different outputs in the later multiplot using getSpatialMap_comb.

plotRange

A boolean showing whether the range will be plotted.

member

A number showing which member is selected to get, if the dataset has a "member" dimension. Default is NULL, if no member assigned, and there is a "member" in dimensions, the mean value of the members will be taken.

omitNA

A boolean showing whether the missing value is omitted.

info

A boolean showing whether the information of the map, e.g., max, mean ..., default is FALSE.

...

title, x, y showing the title and x and y axis of the plot. e.g. title = 'aaa'

Details

There are following methods to be selected, "annual": annual rainfall of each year is plotted. "winter", "spring", "autumn", "summer": seasonal rainfall of each year is plotted. Month(number 1 to 12): month rainfall of each year is plotted, e.g. march rainfall of each year. "meanMonthly": the mean monthly rainfall of each month over the whole period.

#Since "winter" is a crossing year, 12, 1, 2, 12 is in former year, and 1, 2 are in latter year. #so winter belongs to the latter year.

cell representing the location of the cell, NOTE: this location means the index of the cell, IT IS NOT THE LONGITUDE AND LATITUDE. e.g., cell = c(2, 3), the program will take the 2nd longitude and 3rd latitude, by the increasing order. Longitude comes first.

It is a generic function, if in your case you need to debug, please see ?debug() for how to debug S4 method.

Value

The calculated mean value of the input time series and the plot of the result.

References

  • Hadley Wickham (2007). Reshaping Data with the reshape Package. Journal of Statistical Software, 21(12), 1-20. URL http://www.jstatsoft.org/v21/i12/.

  • H. Wickham. ggplot2: elegant graphics for data analysis. Springer New York, 2009.

  • R Core Team (2015). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.

Examples

#gridData provided by package is the result of \code{loadNcdf()}
data(tgridData)
b1 <- getPreciBar(tgridData, method = 'annual')
b2 <- getPreciBar(tgridData, method = 'meanMonthly')

data(testdl)
TS  <- testdl[[1]]
a <- getPreciBar(TS, method = 'spring')
# if info = T, the information will be given at the bottom.
a <- getPreciBar(TS, method = 'spring', info = TRUE)


# More examples can be found in the user manual on https://yuanchao-xu.github.io/hyfo/


Yuanchao-Xu/hyfo documentation built on Aug. 29, 2023, 4:57 a.m.