non_overlapping_sample: non_overlapping_sample take a sample with non overlapping...

Description Usage Arguments Examples

Description

non_overlapping_sample take a sample with non overlapping elements for the same id (i.e. client id) according to a window of days.

Usage

1
non_overlapping_sample(tbla, date_field, id_field, window_days)

Arguments

tbla

table with data. It has to have the date field and the id field (could be client id).

date_field

name of the date field used to create the window of days.

id_field

name of the id (client id).

window_days

number of days that are going to be in each side of the selected date in the sample.

Examples

1
2
3
4
5
6
set.seed(1)
library(lubridate)
sem = sample(seq.Date(ymd(20150101),ymd(20180101),1), 3000, replace = T)
base = data.frame(fc_fin_semana = sem, cd_cliente=round(runif(3000)*10,0))
base=base[!duplicated(base),]
non_overlapping_sample(base, date_field='fc_fin_semana', 'cd_cliente', 90)

GabyP/categorizaOrdinales documentation built on Sept. 21, 2020, 1:42 p.m.