Uses a vectory specifying whether data falls into an event to reshape data, aligning by the onset of the event
align_events(
df,
events,
dovars = names(df),
leng_threshold,
before,
after,
do_norm = FALSE,
nbins = 6,
normbin = 2
)
A data frame containing all data continuously along time, required columns: "site", "date"
.
A data frame with columns idx_start
and len
, specifying event start and length, referring to the row index of df
.
events
is the output of a function call to get_consecutive
.
A vector of character strings specifying which columns (by column name) of df
to re-arrange.
An integer specifying the minum number of consecutive dates required to define an event.
All events of length lower than leng_threshold
are dropped.
An integer specifying the number of days before the event onset to be retained in re-arranged data
An integer specifying the number of days after the event onset to be retained in re-arranged data
A logical specifying whether re-arranged data is to be normalised by the median value of the bin
(number of bins given by argument nbins
) before the event onset, given by argument normbin
. Defaults to FALSE
.
An integer, specifying the number of bins used to determine median values before event onset. Only used when do_norm=TRUE
. Defaults to 6.
An integer, specifying the bin number just before the event onset, used for normalisation. Only used when do_norm=TRUE
. Defaults to 2.
A named list of data frames (list( "df_idx_event", "df_idx_event_aggbyidx_event")
) containing data from all events and before + after
dates (relative to event onset) with additional columns named "inst"
, defining the event number (instance), and "idx_event"
, defining
the date relative to the respective event onset. The data frame "df_idx_event"
contains rearranged, but otherwise unchanged data (unless
do_norm
=TRUE). The data frame "df_idx_event_aggbyidx_event"
containes data aggregated across events with the mean and quantiles given for each
"idx_event"
.