我需要创建一个类似于以下内容的标志:
当条件为TRUE时,标志的值始终为1
ID Date Condition Flag Amount
1 2015.04.01 False 0 0
1 2015.05.01 True 1 0
1 2015.06.01 True 1 0
在条件设置为false后的一年内,该标志的值始终为1
ID Date Condition Flag Amount
1 2015.04.01 False 0 0
1 2015.05.01 True 1 0
1 2015.06.01 True 1 0
1 2015.07.01 False 1 0
1 2015.08.01 False 1 0
1 2015.09.01 False 1 0
1 2015.10.01 False 1 0
1 2015.11.01 False 1 0
1 2015.12.01 False 1 0
1 2016.01.01 False 1 0
1 2016.02.01 False 1 0
1 2016.03.01 False 1 0
1 2016.04.01 False 1 0
1 2016.05.01 False 1 0
1 2016.06.01 False 1 0
1 2016.07.01 False 0 0
如果Amount列的值不为0,则年份重新开始,另一年的标志为1
ID Date Condition Flag Amount
1 2015.04.01 False 0 0
1 2015.05.01 True 1 0
1 2015.06.01 True 1 0
1 2015.07.01 False 1 0
1 2015.08.01 False 1 0
1 2015.09.01 False 1 0
1 2015.10.01 False 1 0
1 2015.11.01 False 1 83
1 2015.12.01 False 1 0
1 2016.01.01 False 1 0
1 2016.02.01 False 1 0
1 2016.03.01 False 1 0
1 2016.04.01 False 1 0
1 2016.05.01 False 1 0
1 2016.06.01 False 1 0
1 2016.07.01 False 1 0
1 2016.08.01 False 1 0
1 2016.09.01 False 1 0
1 2016.10.01 False 1 0
1 2016.11.01 False 1 0
1 2016.12.01 False 0 0
其他信息:
要点: 如果金额字段为0且条件为TRUE后一年的条件为FALSE,则该标志只能重置为0
请帮助我完成本专栏。
数据:
> dput(DT)
structure(list(ID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L), Date = c("2014.02.01", "2014.03.01",
"2014.04.01", "2014.05.01", "2014.06.01", "2014.07.01", "2014.08.01",
"2014.09.01", "2014.10.01", "2014.11.01", "2014.12.01", "2015.01.01",
"2015.02.01", "2015.03.01", "2015.04.01", "2015.05.01", "2015.06.01",
"2015.07.01", "2015.08.01", "2015.09.01", "2015.10.01", "2015.11.01",
"2015.12.01", "2016.01.01", "2016.02.01", "2016.03.01", "2016.04.01",
"2016.05.01", "2016.06.01", "2016.07.01", "2016.08.01", "2016.09.01",
"2016.10.01", "2016.11.01", "2016.12.01", "2017.01.01", "2017.02.01",
"2017.03.01", "2017.04.01", "2017.05.01", "2017.06.01", "2017.07.01",
"2017.08.01", "2017.09.01", "2017.10.01", "2017.11.01", "2017.12.01",
"2018.01.01", "2018.02.01", "2018.03.01", "2018.04.01", "2018.05.01",
"2018.06.01", "2015.01.01", "2015.02.01", "2015.03.01", "2015.04.01",
"2015.05.01", "2015.06.01", "2015.07.01", "2015.08.01", "2015.09.01",
"2015.10.01", "2012.01.01", "2012.02.01", "2012.03.01", "2012.04.01",
"2012.05.01", "2012.06.01", "2012.07.01", "2012.08.01", "2012.09.01",
"2012.10.01", "2012.11.01", "2012.12.01", "2013.01.01", "2013.02.01",
"2013.03.01", "2013.04.01", "2013.05.01", "2013.06.01", "2013.07.01",
"2013.08.01", "2013.09.01", "2013.10.01", "2013.11.01", "2013.12.01",
"2014.01.01", "2014.02.01", "2014.03.01", "2014.04.01", "2014.05.01",
"2014.06.01", "2014.07.01", "2014.08.01", "2014.09.01", "2014.10.01",
"2014.11.01", "2014.12.01", "2015.01.01", "2015.02.01", "2015.03.01",
"2015.04.01", "2015.05.01", "2015.06.01", "2015.07.01", "2015.08.01",
"2015.09.01", "2015.10.01", "2015.11.01", "2015.12.01", "2016.01.01",
"2016.02.01", "2016.03.01", "2016.04.01", "2016.05.01", "2016.06.01",
"2016.07.01", "2016.08.01", "2016.09.01", "2016.10.01", "2016.11.01",
"2016.12.01", "2017.01.01", "2017.02.01", "2017.03.01", "2017.04.01",
"2017.05.01", "2017.06.01", "2017.07.01", "2017.08.01", "2014.11.01",
"2014.12.01", "2015.01.01", "2015.02.01", "2015.03.01", "2015.04.01",
"2015.05.01", "2015.06.01", "2015.07.01", "2015.08.01", "2015.09.01",
"2015.10.01", "2015.11.01", "2015.12.01", "2016.01.01", "2016.02.01",
"2016.03.01", "2016.04.01", "2016.05.01", "2016.06.01", "2016.07.01",
"2016.08.01", "2016.09.01", "2016.10.01", "2016.11.01", "2016.12.01",
"2017.01.01", "2017.02.01", "2017.03.01", "2017.04.01", "2017.05.01",
"2017.06.01", "2017.07.01", "2017.08.01", "2012.12.01", "2013.01.01",
"2013.02.01", "2013.03.01", "2013.04.01", "2013.05.01", "2013.06.01",
"2013.07.01", "2013.08.01", "2013.09.01", "2013.10.01", "2013.11.01",
"2013.12.01", "2014.01.01", "2014.02.01", "2014.03.01", "2014.04.01",
"2014.05.01", "2014.06.01", "2014.07.01", "2014.08.01", "2014.09.01",
"2014.10.01", "2014.11.01", "2014.12.01", "2015.01.01", "2015.02.01",
"2015.03.01", "2015.04.01", "2011.02.01", "2011.03.01", "2011.04.01",
"2011.05.01", "2011.06.01", "2011.07.01", "2011.08.01", "2011.09.01",
"2011.10.01", "2011.11.01", "2011.12.01", "2012.01.01", "2012.02.01",
"2012.03.01", "2012.04.01", "2012.05.01", "2012.06.01", "2012.07.01",
"2012.08.01", "2012.09.01", "2012.10.01", "2012.11.01", "2012.12.01",
"2013.01.01", "2013.02.01", "2013.03.01", "2013.04.01", "2013.05.01",
"2013.06.01", "2013.07.01", "2013.08.01", "2013.09.01", "2013.10.01",
"2013.11.01", "2013.12.01", "2014.01.01", "2014.02.01", "2014.03.01",
"2014.04.01", "2014.05.01", "2014.06.01", "2014.07.01", "2014.08.01",
"2014.09.01", "2014.10.01", "2014.11.01", "2014.12.01", "2015.01.01",
"2015.02.01", "2015.03.01", "2015.04.01", "2015.05.01", "2015.06.01",
"2015.07.01", "2015.08.01", "2015.09.01", "2015.10.01", "2015.11.01",
"2015.12.01", "2016.01.01", "2016.02.01", "2016.03.01", "2016.04.01",
"2016.05.01", "2016.06.01", "2016.07.01", "2016.08.01", "2016.09.01",
"2016.10.01", "2016.11.01", "2016.12.01", "2017.01.01", "2017.02.01",
"2017.03.01", "2017.04.01", "2017.05.01", "2017.06.01", "2017.07.01"
), Condition = c(FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), Amount = c(10L, 25L,
20L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 20L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 35L, 70L, 980L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 20L, 75L,
30L, 0L, 0L, 0L, 0L, 15L, 0L, 0L, 0L, 0L, 0L, 0L, 90L, 90L, 90L,
150L, 150L, 15L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 15L, 50L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 15L, 30L, 75L, 0L, 0L, 0L, 0L, 15L, 34L, 93L, 0L, 0L, 0L,
0L, 20L, 30L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
30L, 0L, 0L, 0L, 0L, 0L, 0L, 120L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("ID", "Date",
"Condition", "Amount"), class = c("data.table", "data.frame"), row.names = c(NA,
-272L), .internal.selfref = <pointer: 0x00000000026b0788>)
答案 0 :(得分:0)
可能的(不幸的是有点复杂)解决方案:
# load needed packages
library(zoo)
library(lubridate)
library(data.table)
# line 1: convert 'Date' column to date-format
# line 2: create new column 'datetrue' with only the dates for which the Condition is TRUE
# line 3: fill 'datetrue' forward with 'na.locf'
# line 4: create 'dtetrue2' for the rows where 'datetrue' is not NA and
# 'Amount' is higher than zero
# line 5: fill 'datetrue2' forward with 'na.locf'
# line 6: replace 'datetrue' with maximum of 'datetrue' & 'datetrue2' with 'pmax'
# line 7: create 'flag' and set to 'one' where Date is smaller then
# or equal to 'datetrue'
# line 8: remove the 'datetrue' & 'datetrue2' columns
DT[, Date := as.IDate(Date, '%Y.%m.%d')
][!!Condition, datetrue := Date %m+% lubridate::years(1)
][, datetrue := na.locf(datetrue, na.rm = FALSE), by = ID
][!is.na(datetrue) & Amount > 0, datetrue2 := Date %m+% lubridate::years(1), by = ID
][, datetrue2 := na.locf(datetrue2, na.rm = FALSE), by = ID
][, datetrue := pmax(datetrue, datetrue2, na.rm = TRUE), by = ID
][, flag := as.integer(Date <= datetrue), by = ID
][, c('datetrue','datetrue2') := NULL][]
给出了(显示ID == 3
的结果):
> DT[ID == 3] ID Date Condition Amount flag 1: 3 2012-01-01 FALSE 0 NA 2: 3 2012-02-01 FALSE 0 NA 3: 3 2012-03-01 FALSE 0 NA 4: 3 2012-04-01 FALSE 0 NA 5: 3 2012-05-01 TRUE 0 1 6: 3 2012-06-01 TRUE 0 1 7: 3 2012-07-01 TRUE 0 1 8: 3 2012-08-01 TRUE 0 1 9: 3 2012-09-01 FALSE 0 1 10: 3 2012-10-01 FALSE 0 1 11: 3 2012-11-01 FALSE 0 1 12: 3 2012-12-01 FALSE 0 1 13: 3 2013-01-01 FALSE 0 1 14: 3 2013-02-01 FALSE 20 1 15: 3 2013-03-01 FALSE 75 1 16: 3 2013-04-01 FALSE 30 1 17: 3 2013-05-01 FALSE 0 1 18: 3 2013-06-01 FALSE 0 1 19: 3 2013-07-01 FALSE 0 1 20: 3 2013-08-01 FALSE 0 1 21: 3 2013-09-01 FALSE 15 1 22: 3 2013-10-01 FALSE 0 1 23: 3 2013-11-01 FALSE 0 1 24: 3 2013-12-01 FALSE 0 1 25: 3 2014-01-01 FALSE 0 1 26: 3 2014-02-01 FALSE 0 1 27: 3 2014-03-01 FALSE 0 1 28: 3 2014-04-01 FALSE 90 1 29: 3 2014-05-01 TRUE 90 1 30: 3 2014-06-01 TRUE 90 1 31: 3 2014-07-01 TRUE 150 1 32: 3 2014-08-01 FALSE 150 1 33: 3 2014-09-01 FALSE 15 1 34: 3 2014-10-01 FALSE 0 1 35: 3 2014-11-01 FALSE 0 1 36: 3 2014-12-01 FALSE 0 1 37: 3 2015-01-01 FALSE 0 1 38: 3 2015-02-01 FALSE 0 1 39: 3 2015-03-01 FALSE 0 1 40: 3 2015-04-01 TRUE 0 1 41: 3 2015-05-01 TRUE 0 1 42: 3 2015-06-01 TRUE 0 1 43: 3 2015-07-01 FALSE 0 1 44: 3 2015-08-01 FALSE 0 1 45: 3 2015-09-01 FALSE 0 1 46: 3 2015-10-01 FALSE 0 1 47: 3 2015-11-01 FALSE 0 1 48: 3 2015-12-01 FALSE 0 1 49: 3 2016-01-01 FALSE 0 1 50: 3 2016-02-01 FALSE 0 1 51: 3 2016-03-01 FALSE 15 1 52: 3 2016-04-01 FALSE 50 1 53: 3 2016-05-01 FALSE 0 1 54: 3 2016-06-01 FALSE 0 1 55: 3 2016-07-01 FALSE 0 1 56: 3 2016-08-01 FALSE 0 1 57: 3 2016-09-01 FALSE 0 1 58: 3 2016-10-01 FALSE 0 1 59: 3 2016-11-01 FALSE 0 1 60: 3 2016-12-01 FALSE 0 1 61: 3 2017-01-01 FALSE 0 1 62: 3 2017-02-01 FALSE 0 1 63: 3 2017-03-01 FALSE 0 1 64: 3 2017-04-01 FALSE 0 1 65: 3 2017-05-01 FALSE 0 0 66: 3 2017-06-01 FALSE 0 0 67: 3 2017-07-01 FALSE 0 0 68: 3 2017-08-01 FALSE 0 0
使用过的数据:
DT <- structure(list(ID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, NA, NA, NA),
Date = c("2014.02.01", "2014.03.01", "2014.04.01", "2014.05.01", "2014.06.01", "2014.07.01", "2014.08.01", "2014.09.01", "2014.10.01", "2014.11.01", "2014.12.01", "2015.01.01", "2015.02.01", "2015.03.01", "2015.04.01", "2015.05.01", "2015.06.01", "2015.07.01", "2015.08.01", "2015.09.01", "2015.10.01", "2015.11.01", "2015.12.01", "2016.01.01", "2016.02.01", "2016.03.01", "2016.04.01", "2016.05.01", "2016.06.01", "2016.07.01", "2016.08.01", "2016.09.01", "2016.10.01", "2016.11.01", "2016.12.01", "2017.01.01", "2017.02.01", "2017.03.01", "2017.04.01", "2015.01.01", "2015.02.01", "2015.03.01", "2015.04.01", "2015.05.01", "2015.06.01", "2015.07.01", "2015.08.01", "2015.09.01", "2015.10.01", "2012.01.01", "2012.02.01", "2012.03.01", "2012.04.01", "2012.05.01", "2012.06.01", "2012.07.01", "2012.08.01", "2012.09.01", "2012.10.01", "2012.11.01", "2012.12.01", "2013.01.01", "2013.02.01", "2013.03.01", "2013.04.01", "2013.05.01", "2013.06.01", "2013.07.01", "2013.08.01", "2013.09.01", "2013.10.01", "2013.11.01", "2013.12.01", "2014.01.01", "2014.02.01", "2014.03.01", "2014.04.01", "2014.05.01", "2014.06.01", "2014.07.01", "2014.08.01", "2014.09.01", "2014.10.01", "2014.11.01", "2014.12.01", "2015.01.01", "2015.02.01", "2015.03.01", "2015.04.01", "2015.05.01", "2015.06.01", "2015.07.01", "2015.08.01", "2015.09.01", "2015.10.01", "2015.11.01", "2015.12.01", "2016.01.01", "2016.02.01", "2016.03.01", "2016.04.01", "2016.05.01", "2016.06.01", "2016.07.01", "2016.08.01", "2016.09.01", "2016.10.01", "2016.11.01", "2016.12.01", "2017.01.01", "2017.02.01", "2017.03.01", "2017.04.01", "2017.05.01", "2017.06.01", "2017.07.01", "2017.08.01", "2014.11.01", "2014.12.01", "2015.01.01", "2015.02.01", "2015.03.01", "2015.04.01", "2015.05.01", "2015.06.01", "2015.07.01", "2015.08.01", "2015.09.01", "2015.10.01", "2015.11.01", "2015.12.01", "2016.01.01", "2016.02.01", "2016.03.01", "2016.04.01", "2016.05.01", "2016.06.01", "2016.07.01", "2016.08.01", "2016.09.01", "2016.10.01", "2016.11.01", "2016.12.01", "2017.01.01", "2017.02.01", "2017.03.01", "2017.04.01", "2017.05.01", "2017.06.01", "2017.07.01", "2017.08.01", "2012.12.01", "2013.01.01", "2013.02.01", "2013.03.01", "2013.04.01", "2013.05.01", "2013.06.01", "2013.07.01", "2013.08.01", "2013.09.01", "2013.10.01", "2013.11.01", "2013.12.01", "2014.01.01", "2014.02.01", "2014.03.01", "2014.04.01", "2014.05.01", "2014.06.01", "2014.07.01", "2014.08.01", "2014.09.01", "2014.10.01", "2014.11.01", "2014.12.01", "2015.01.01", "2015.02.01", "2015.03.01", "2015.04.01", "2011.02.01", "2011.03.01", "2011.04.01", "2011.05.01", "2011.06.01", "2011.07.01", "2011.08.01", "2011.09.01", "2011.10.01", "2011.11.01", "2011.12.01", "2012.01.01", "2012.02.01", "2012.03.01", "2012.04.01", "2012.05.01", "2012.06.01", "2012.07.01", "2012.08.01", "2012.09.01", "2012.10.01", "2012.11.01", "2012.12.01", "2013.01.01", "2013.02.01", "2013.03.01", "2013.04.01", "2013.05.01", "2013.06.01", "2013.07.01", "2013.08.01", "2013.09.01", "2013.10.01", "2013.11.01", "2013.12.01", "2014.01.01", "2014.02.01", "2014.03.01", "2014.04.01", "2014.05.01", "2014.06.01", "2014.07.01", "2014.08.01", "2014.09.01", "2014.10.01", "2014.11.01", "2014.12.01", "2015.01.01", "2015.02.01", "2015.03.01", "2015.04.01", "2015.05.01", "2015.06.01", "2015.07.01", "2015.08.01", "2015.09.01", "2015.10.01", "2015.11.01", "2015.12.01", "2016.01.01", "2016.02.01", "2016.03.01", "2016.04.01", "2016.05.01", "2016.06.01", "2016.07.01", "2016.08.01", "2016.09.01", "2016.10.01", "2016.11.01", "2016.12.01", "2017.01.01", "2017.02.01", "2017.03.01", "2017.04.01", "2017.05.01", "2017.06.01", "2017.07.01", "", "", ""),
Condition = c(FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, NA, NA, NA),
Amount = c(10L, 25L, 20L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 35L, 70L, 980L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 20L, 75L, 30L, 0L, 0L, 0L, 0L, 15L, 0L, 0L, 0L, 0L, 0L, 0L, 90L, 90L, 90L, 150L, 150L, 15L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 15L, 50L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 15L, 30L, 75L, 0L, 0L, 0L, 0L, 15L, 34L, 93L, 0L, 0L, 0L, 0L, 20L, 30L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 30L, 0L, 0L, 0L, 0L, 0L, 0L, 120L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, NA, NA, NA)),
.Names = c("ID", "Date", "Condition", "Amount"), row.names = c(NA, -261L), class = "data.frame")
setDT(DT)