inst2daily: Extracting maximas

View source: R/inst2daily.R

inst2dailyR Documentation

Extracting maximas

Description

Given a data.frame or matrix, keeps rows which correspond to the maximum for each level of indFac.

Usage

inst2daily(zz, indFac, indVec)

Arguments

zz

the dataset of matrix whcih should be processed

indFac

the column number which identifies the grouping column. The column doesn't need to be a factor (as.factor enforced). Use ordere factors if the data need to be in the same order.

indVec

the column number which identifies the variable of interest column.

Details

As the name betrays this was built to process 15-minutes data and identify daily maxima. It still work to extract monthly or annual maxima.

Value

an object of the same class and size as zz, in which only values which are the maximum value for the indVec column in the indFac groups are kept.

Examples

set.seed(145)
zz <- data.frame(month = c(rep("Jan",5),rep("Feb",5),rep("Mar",5),rep("Apr",5)), 
                flow = rnorm(20,50,6),
                day=rep(c(2,9,16,23,28),4))
inst2daily(zz, indVec=2, indFac = 1)
zz$month <- factor(zz$month, levels = c("Jan","Feb","Mar","Apr"), ordered = TRUE)
inst2daily(zz, indVec=2, indFac = 1)

ilapros/ilaprosUtils documentation built on April 6, 2023, 4:44 a.m.