R/sigex.load.r

Defines functions sigex.load

Documented in sigex.load

#' Load data into a time series object
#'
#' @param data A T x N matrix, corresponding to N time series of length T
#' @param start.date Date of first time obersvation; the
#'			 format is c(year,season)
#' @param period Number of seasons per year
#' @param epithets Vector of N character strings, giving a short name for
#'			 each series
#' @param plot Boolean, whether to plot the series (max of N=10 allowed)
#'
#' @return data.ts: a T x N matrix ts object
#' @export
#'

sigex.load <- function(data,start.date,period,epithets,plot=FALSE)
{

	##########################################################################
	#
	#	sigex.load
	# 	    Copyright (C) 2017  Tucker McElroy
	#
	#    This program is free software: you can redistribute it and/or modify
	#    it under the terms of the GNU General Public License as published by
	#    the Free Software Foundation, either version 3 of the License, or
	#    (at your option) any later version.
	#
	#    This program is distributed in the hope that it will be useful,
	#    but WITHOUT ANY WARRANTY; without even the implied warranty of
	#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	#    GNU General Public License for more details.
	#
	#    You should have received a copy of the GNU General Public License
	#    along with this program.  If not, see <https://www.gnu.org/licenses/>.
	#
	############################################################################

	################# Documentation #####################################
	#
	#	Purpose: load data into a time series object
	#
	#	Inputs:
	#		data: a T x N matrix, corresponding to N time series of length T
	#		start.date: date of first time obersvation; the
	#			 format is c(year,season)
	#		period: number of seasons per year
	#		epithets: vector of N character strings, giving a short name for
	#			 each series
	#		plot: boolean, whether to plot the series (max of N=10 allowed)
	#	Outputs:
	#		data.ts: a T x N matrix ts object
	#
	####################################################################

	data.ts <- ts(data,start=start.date,frequency=period,names=epithets)
 	if(plot) { plot(data.ts,xlab="Year") }

	return(data.ts)
}
jlivsey/sigex documentation built on March 20, 2024, 3:17 a.m.