Skip to content

Commit

Permalink
Remove elements that occur before the first bin when splitting by bins
Browse files Browse the repository at this point in the history
This change is in-line with the current treatment of the elements that
occur after the last bin.

Further, this fixes a minor "bug" where bin indecees are used to
determine bin labels by indexing into a list of labels. Elements before
the first bin received bin index 0, however, R is 1-indexed. Note: This
"bug" did not cause problems because the bin with the incorrect label
will be ignored later anyways.

Works towards se-sic#267.

Signed-off-by: Maximilian Löffler <s8maloef@stud.uni-saarland.de>
  • Loading branch information
MaLoefUDS committed Aug 27, 2024
1 parent a22fffb commit 1d804f8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions util-split.R
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,8 @@ split.data.by.time.or.bins = function(project.data, splitting.length, bins, spli
findInterval(df[["date"]], bins.date, all.inside = FALSE)
## split data according to df.bins
df.split = split(df, df.bins)
## remove data before the first bin
df.split = df.split[names(df.split) != "0"]
## add proper labels/names
names(df.split) = sapply(as.integer(names(df.split)), function(bin) bins[bin])
return(df.split)
Expand Down

0 comments on commit 1d804f8

Please sign in to comment.