distinct_time: select distinct rows (relative to time)

Description Usage Arguments Value Examples

View source: R/agent-to-aggregate.R

Description

This function is like distinct but it is only relative to the row ordering (it is also an internal function)

Usage

1
distinct_time(df, ignore_idx = NULL)

Arguments

df

data frame, which row index related to ordering of time

ignore_idx

index of columns of data frame that shouldn't be examined relative to the "distinct" decision.

Value

df_updated an updated data frame with only rows with new information relative to time ordering

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
df <- data.frame(t = 1:100, x = rep(c(1,1,2,2,3,3),
                                    length = 100),
                 y = rep(c(1,1,1,2,2,2,3,3,3),
                         length = 100))

df_filtered <- EpiCompare:::distinct_time(df, 1)
dim(df_filtered) # c(67,3)                  
df_filtered 
# same as: 
df[!(1:100 %in% cumsum(rep(c(2,4), length = 33))),]

skgallagher/EpiCompare documentation built on Sept. 14, 2021, 5:45 a.m.