Commit 6ee46620 authored by unknown's avatar unknown
Browse files

#3896 The function SeriesAggreg() accepts input dates in both POSIX formats...

#3896 The function SeriesAggreg() accepts input dates in both POSIX formats (POSIXct and POSIXlt). The output is in POSIXct format.
parent 162c4e96
......@@ -7,10 +7,16 @@ SeriesAggreg <- function(TabSeries, TimeFormat, NewTimeFormat, ConvertFun, YearF
if(is.null(TabSeries) ){ stop("TabSeries must be a dataframe containing the dates and data to be converted \n"); return(NULL); }
if(!is.data.frame(TabSeries)){ stop("TabSeries must be a dataframe containing the dates and data to be converted \n"); return(NULL); }
if(ncol(TabSeries)<2){ stop("TabSeries must contain at least two columns (including the coulmn of dates \n"); return(NULL); }
if("POSIXlt" %in% class(TabSeries[,1]) == FALSE & "POSIXct" %in% class(TabSeries[,1]) == FALSE){ stop("TabSeries first column must be a vector of class POSIXlt or POSIXct \n"); return(NULL); }
##check_TimeFormat
if(!any(class(TabSeries[,1]) %in% "POSIXt")) {
stop("TabSeries first column must be a vector of class POSIXlt or POSIXct \n")
return(NULL)
}
if(any(class(TabSeries[,1]) %in% "POSIXlt")) {
TabSeries[,1] <- as.POSIXct(TabSeries[,1])
}
for(iCol in 2:ncol(TabSeries)){
if(!is.numeric(TabSeries[,iCol])){ stop("TabSeries columns (other than the first one) be of numeric class \n"); return(NULL); } }
##check_TimeFormat
if(is.null( TimeFormat)){ stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n"); return(NULL); }
if(!is.vector( TimeFormat)){ stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n"); return(NULL); }
if(!is.character(TimeFormat)){ stop("TimeFormat must be 'hourly', 'daily', 'monthly' or 'yearly' \n"); return(NULL); }
......
......@@ -7,7 +7,7 @@ SeriesAggreg(TabSeries, TimeFormat, NewTimeFormat, ConvertFun,
YearFirstMonth = 1, TimeLag = 0, verbose = TRUE)
}
\arguments{
\item{TabSeries}{[POSIXlt+numeric] dataframe containing the vector of dates and the time series values}
\item{TabSeries}{[POSIXt+numeric] dataframe containing the vector of dates (POSIXt) and the time series values numeric)}
\item{TimeFormat}{[character] desired format (i.e. "hourly", "daily", "monthly" or "yearly")}
......@@ -22,7 +22,7 @@ SeriesAggreg(TabSeries, TimeFormat, NewTimeFormat, ConvertFun,
\item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = FALSE}
}
\value{
[POSIXlt+numeric] dataframe containing a vector of aggregated dates and time series values
[POSIXct+numeric] dataframe containing a vector of aggregated dates (POSIXct) and time series values numeric)
}
\description{
Conversion of time series to another time step (aggregation only). \cr
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment