View source: R/temporal_means.R
temporal_means | R Documentation |
This function computes temporal empirical means averaged per time unit. This function can take either a stars object or a dataframe. Input arguments differ for each case. The function autoplot plots the output.
temporal_means(x, ...) ## S3 method for class 'data.frame' temporal_means(x, t_col, z_col, id_col, ...) ## S3 method for class 'stars' temporal_means(x, ...) ## S3 method for class 'temporalmeans' autoplot( object, ylab = "Value", xlab = "Time", legend_title = "", title = "Temporal Empirical Means", ... )
x |
A stars object or a dataframe. Arguments differ according to the input type. |
... |
Other arguments currently ignored. |
t_col |
For dataframes: the time column. Time must be a set of discrete integer values. |
z_col |
For dataframes: the The quantity of interest that will be plotted. Eg. temperature. |
id_col |
The column of the location id. |
object |
For autoplot: the output of the function ‘temporal_means’. |
ylab |
The y label. |
xlab |
The x label. |
legend_title |
For autoplot: the title for the legend. |
title |
The graph title. |
An object of class temporalmeans containing the averages and the original data in two dataframes.
# dataframe example data(NOAA_df_1990) library(dplyr) Tmax <- filter(NOAA_df_1990, # subset the data proc == "Tmax" & # extract max temperature month %in% 5:9 & # May to July year == 1993) # year 1993 Tmax$t <- Tmax$julian - min(Tmax$julian) + 1 # create a new time variable starting at 1 tem <- temporal_means(Tmax, t_col = 'date', z_col = 'z', id_col = 'id') autoplot(tem) # stars example library(stars) library(dplyr) library(units) # Example prec_file = system.file("nc/test_stageiv_xyt.nc", package = "stars") prec <- read_ncdf(prec_file) temporal_means(prec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.