I have two different input data tables
sw table and Sub_Index table. I'm trying to perform an operation which involves these two input data tables but i'm trying to run this operation based on one field called "ASHRAE" by sub setting these two data tables using this field.
I have split the two input data tables into multiple data tables based on the values from this field "ASHRAE" of the two input tables.
I'm finding it difficult to run this operation across the sub set table groups and store it in a one final table.
Could you please advise
#input tables
sw<- structure(list(Production.Period = c("6/9/2018", "6/9/2018",
"21-09-18", "21-09-18", "21-09-18", "21-09-18", "21-09-18", "21-09-18",
"21-09-18", "21-09-18", "21-09-18", "21-09-18", "21-09-18", "21-09-18",
"21-09-18", "21-09-18", "21-09-18", "21-09-18", "21-09-18", "21-09-18",
"21-09-18", "21-09-18", "4/10/2018", "4/10/2018", "4/10/2018",
"4/10/2018", "4/10/2018", "4/10/2018"), Date.Installed = c("19-06-19",
"4/5/2019", "9/2/2019", "24-01-19", "28-01-19", "14-01-19", "8/5/2020",
"6/7/2019", "24-01-19", "2/3/2020", "2/4/2019", "14-08-20", "15-04-20",
"14-11-18", "10/5/2019", "21-05-19", "15-10-19", "29-10-19",
"29-10-19", "30-01-20", "9/5/2020", "7/11/2019", "4/5/2020",
"17-05-19", "22-09-20", "25-08-20", "4/7/2019", "28-08-19"),
Unit.Family = c("X1", "X1", "X1", "X1", "X1", "X1", "X1",
"X1", "X1", "X1", "X1", "X1", "X1", "X1", "X1", "X1", "X1",
"X1", "X1", "X1", "X1", "X1", "X1", "X1", "X1", "X1", "X1",
"X1"), Unit.Type = c("X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X"), ASHRAE = c("2A",
"2B", "2B", "2B", "2B", "2B", "2A", "2B", "2B", "2B", "2A",
"2B", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "", "", "", "", "", ""), Failure.Date = c(NA, NA, NA,
NA, "13-02-19", NA, NA, NA, NA, NA, NA, NA, NA, NA, "20-03-20",
NA, NA, "6/2/2020", "1/4/2020", NA, NA, "23-03-22", "1/2/2022",
NA, NA, NA, NA, NA), `Failure.Date.month/year` = c(NA, NA,
NA, NA, "19-Feb", NA, NA, NA, NA, NA, NA, NA, NA, NA, "20-Mar",
NA, NA, "20-Feb", "20-Apr", NA, NA, "22-Mar", "22-Feb", NA,
NA, NA, NA, NA), Install.To.Fail.Lag.Days = c(NA, NA, NA,
NA, 16L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 315L, NA, NA,
100L, 155L, NA, NA, 867L, 638L, NA, NA, NA, NA, NA), Install.To.Fail.Lag.Months = c(NA,
NA, NA, NA, 1L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 10L,
NA, NA, 4L, 6L, NA, NA, 28L, 21L, NA, NA, NA, NA, NA), Install.Date = c(NA,
NA, NA, NA, "28-01-19", NA, NA, NA, NA, NA, NA, NA, NA, NA,
"10/5/2019", NA, NA, "29-10-19", "29-10-19", NA, NA, "7/11/2019",
"4/5/2020", NA, NA, NA, NA, NA), STATUS = c(1L, 1L, 1L, 1L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L), Functional_days = c(1106L,
1152L, 1236L, 1252L, 16L, 1262L, 782L, 1089L, 1252L, 849L,
1184L, 684L, 805L, 1323L, 315L, 1135L, 988L, 100L, 155L,
881L, 781L, 867L, 638L, 1139L, 645L, 673L, 1091L, 1036L),
FailDate = c("29-06-22", "29-06-22", "29-06-22", "29-06-22",
"13-02-19", "29-06-22", "29-06-22", "29-06-22", "29-06-22",
"29-06-22", "29-06-22", "29-06-22", "29-06-22", "29-06-22",
"20-03-20", "29-06-22", "29-06-22", "6/2/2020", "1/4/2020",
"29-06-22", "29-06-22", "23-03-22", "1/2/2022", "29-06-22",
"29-06-22", "29-06-22", "29-06-22", "29-06-22"), DayOFYear = c(NA,
NA, NA, NA, 44L, NA, NA, NA, NA, NA, NA, NA, NA, NA, 80L,
NA, NA, 37L, 92L, NA, NA, 82L, 32L, NA, NA, NA, NA, NA),
StartDayOFYear = c(170L, 124L, 40L, 24L, 28L, 14L, 129L,
187L, 24L, 62L, 92L, 227L, 106L, 318L, 130L, 141L, 288L,
302L, 302L, 30L, 130L, 311L, 125L, 137L, 266L, 238L, 185L,
240L), EndDayOFYear = c(180L, 180L, 180L, 180L, 44L, 180L,
180L, 180L, 180L, 180L, 180L, 180L, 180L, 180L, 80L, 180L,
180L, 37L, 92L, 180L, 180L, 82L, 32L, 180L, 180L, 180L, 180L,
180L), YearsInWarranty = c(3L, 3L, 3L, 3L, 0L, 3L, 2L, 2L,
3L, 2L, 3L, 1L, 2L, 3L, 0L, 3L, 2L, 0L, 0L, 2L, 2L, 2L, 1L,
3L, 1L, 1L, 2L, 2L), ID = c(1L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
13L, 18L, 28L, 39L, 54L, 56L, 66L, 70L, 71L, 72L, 73L, 74L,
77L, 78L, 321L, 322L, 324L, 325L, 327L, 328L)), row.names = c(NA,
-28L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x000001c0111a1ef0>)
Sub_Index<- structure(list(X = c("X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X", "X",
"X", "X", "X", "X", "X", "X"), Ashrae_zones = c("2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A", "2A",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B", "2B",
"2B", "2B", "2B", "", "", "", "", "", "", "", "", "", ""), DayOFYear = c(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L,
55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L,
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L,
81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L,
94L, 95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L,
106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L,
117L, 118L, 119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L,
128L, 129L, 130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L,
139L, 140L, 141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L,
150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L,
161L, 162L, 163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L,
172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L,
183L, 184L, 185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L,
194L, 195L, 196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L, 204L,
205L, 206L, 207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L,
216L, 217L, 218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L,
227L, 228L, 229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L,
238L, 239L, 240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L,
249L, 250L, 251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L,
260L, 261L, 262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L,
271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L,
282L, 283L, 284L, 285L, 286L, 287L, 288L, 289L, 290L, 291L, 292L,
293L, 294L, 295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L,
304L, 305L, 306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L,
315L, 316L, 317L, 318L, 319L, 320L, 321L, 322L, 323L, 324L, 325L,
326L, 327L, 328L, 329L, 330L, 331L, 332L, 333L, 334L, 335L, 336L,
337L, 338L, 339L, 340L, 341L, 342L, 343L, 344L, 345L, 346L, 347L,
348L, 349L, 350L, 351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L,
359L, 360L, 361L, 362L, 363L, 364L, 365L, 366L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L,
45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L,
58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L,
71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L,
84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L,
97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L,
108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L,
119L, 120L, 121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L,
130L, 131L, 132L, 133L, 134L, 135L, 136L, 137L, 138L, 139L, 140L,
141L, 142L, 143L, 144L, 145L, 146L, 147L, 148L, 149L, 150L, 151L,
152L, 153L, 154L, 155L, 156L, 157L, 158L, 159L, 160L, 161L, 162L,
163L, 164L, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L,
174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L, 184L,
185L, 186L, 187L, 188L, 189L, 190L, 191L, 192L, 193L, 194L, 195L,
196L, 197L, 198L, 199L, 200L, 201L, 202L, 203L, 204L, 205L, 206L,
207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L,
218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L, 228L,
229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 239L,
240L, 241L, 242L, 243L, 244L, 245L, 246L, 247L, 248L, 249L, 250L,
251L, 252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L, 260L, 261L,
262L, 263L, 264L, 265L, 266L, 267L, 268L, 269L, 270L, 271L, 272L,
273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L,
284L, 285L, 286L, 287L, 288L, 289L, 290L, 291L, 292L, 293L, 294L,
295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 304L, 305L,
306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 315L, 316L,
317L, 318L, 319L, 320L, 321L, 322L, 323L, 324L, 325L, 326L, 327L,
328L, 329L, 330L, 331L, 332L, 333L, 334L, 335L, 336L, 337L, 338L,
339L, 340L, 341L, 342L, 343L, 344L, 345L, 346L, 347L, 348L, 349L,
350L, 351L, 352L, 353L, 354L, 355L, 356L, 357L, 358L, 359L, 360L,
361L, 362L, 363L, 364L, 365L, 366L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L), FailRatio = c(0.001099572, 0.004968438, 0.003604154,
0.0053146, 0.003807778, 0.00323763, 0.004255752, 0.004255752,
0.003604154, 0.003278355, 0.003868866, 0.004194665, 0.003685604,
0.003868866, 0.004886988, 0.00315618, 0.003013643, 0.003726329,
0.003685604, 0.003176542, 0.003339442, 0.004540827, 0.003991041,
0.002626756, 0.003685604, 0.002606394, 0.002932193, 0.003583791,
0.003278355, 0.003013643, 0.002647119, 0.002789656, 0.002606394,
0.003522704, 0.00323763, 0.003298717, 0.003339442, 0.002850743,
0.00323763, 0.00307473, 0.003013643, 0.003624516, 0.004561189,
0.003624516, 0.002545306, 0.003359805, 0.003115455, 0.002687844,
0.002911831, 0.004011403, 0.003217267, 0.00315618, 0.003604154,
0.002484219, 0.002850743, 0.003034005, 0.00415394, 0.003115455,
0.002504582, 0.004337202, 0.003644879, 0.002687844, 0.002260232,
0.003950316, 0.002789656, 0.002402769, 0.002321319, 0.002321319,
0.002341682, 0.003339442, 0.003644879, 0.002708206, 0.002300957,
0.003991041, 0.002789656, 0.00431684, 0.00323763, 0.004255752,
0.002769293, 0.002891468, 0.002830381, 0.00199552, 0.003054368,
0.002871106, 0.003665241, 0.002748931, 0.001954795, 0.003868866,
0.003013643, 0.002932193, 0.003196905, 0.003705966, 0.002871106,
0.002260232, 0.002952555, 0.002423132, 0.003257992, 0.003135818,
0.00331908, 0.002626756, 0.002178782, 0.002850743, 0.002504582,
0.002423132, 0.00307473, 0.002932193, 0.001975158, 0.002178782,
0.002789656, 0.002138057, 0.00223987, 0.002199145, 0.002748931,
0.001934433, 0.002382407, 0.002647119, 0.002524944, 0.002219507,
0.003095093, 0.003217267, 0.003339442, 0.002850743, 0.002769293,
0.002586031, 0.003115455, 0.002972918, 0.003013643, 0.002586031,
0.002769293, 0.00307473, 0.002402769, 0.002891468, 0.00215842,
0.003359805, 0.002647119, 0.002015883, 0.00199552, 0.002199145,
0.002626756, 0.002911831, 0.003257992, 0.002606394, 0.002545306,
0.00299328, 0.002362044, 0.001832621, 0.002443494, 0.003278355,
0.002769293, 0.002687844, 0.001710446, 0.002463857, 0.002748931,
0.002871106, 0.003278355, 0.003339442, 0.002260232, 0.002769293,
0.002382407, 0.003095093, 0.003115455, 0.003767054, 0.002647119,
0.002524944, 0.003115455, 0.002667481, 0.002524944, 0.002423132,
0.002932193, 0.003217267, 0.002647119, 0.002871106, 0.001771533,
0.002402769, 0.002565669, 0.003278355, 0.003115455, 0.003115455,
0.003054368, 0.001975158, 0.002524944, 0.002341682, 0.002891468,
0.002810018, 0.000855223, 0.001608634, 0.001771533, 0.002199145,
0.002545306, 0.002769293, 0.002810018, 0.002891468, 0.002647119,
0.001608634, 0.002789656, 0.002260232, 0.00407249, 0.002830381,
0.00323763, 0.002097333, 0.001954795, 0.002321319, 0.002524944,
0.00315618, 0.002626756, 0.003013643, 0.002341682, 0.001812258,
0.002524944, 0.002871106, 0.003278355, 0.002850743, 0.002565669,
0.00223987, 0.001567909, 0.002545306, 0.002911831, 0.002728569,
0.002748931, 0.002260232, 0.002545306, 0.001628996, 0.002382407,
0.002117695, 0.00299328, 0.002300957, 0.002952555, 0.002911831,
0.001628996, 0.002626756, 0.002952555, 0.002586031, 0.002443494,
0.002443494, 0.001812258, 0.001710446, 0.002097333, 0.002687844,
0.003135818, 0.002687844, 0.002138057, 0.00223987, 0.001812258,
0.002423132, 0.002036245, 0.00207697, 0.002708206, 0.002647119,
0.002036245, 0.001608634, 0.001588271, 0.002728569, 0.002300957,
0.002626756, 0.002280595, 0.002402769, 0.001812258, 0.00223987,
0.002504582, 0.002789656, 0.002871106, 0.002565669, 0.001751171,
0.001771533, 0.001690083, 0.002138057, 0.002524944, 0.002586031,
0.002565669, 0.002056608, 0.001730808, 0.00223987, 0.002463857,
0.003828141, 0.003176542, 0.002769293, 0.001751171, 0.00124211,
0.002138057, 0.002769293, 0.002484219, 0.002667481, 0.002260232,
0.001791896, 0.001567909, 0.001852983, 0.001751171, 0.002748931,
0.003848503, 0.001791896, 0.002097333, 0.00124211, 0.001893708,
0.002463857, 0.002524944, 0.002524944, 0.002036245, 0.00191407,
0.001384647, 0.001690083, 0.001893708, 0.002443494, 0.002891468,
0.002362044, 0.002463857, 0.001649359, 0.002524944, 0.002524944,
0.002667481, 0.00323763, 0.002667481, 0.002871106, 0.001486459,
0.002871106, 0.002484219, 0.002932193, 0.002972918, 0.003135818,
0.00223987, 0.002097333, 0.002362044, 0.003115455, 0.003115455,
0.003034005, 0.002484219, 0.001832621, 0.001343922, 0.002015883,
0.00223987, 0.002565669, 0.002484219, 0.001486459, 0.002504582,
0.002911831, 0.003013643, 0.004215027, 0.004724089, 0.004357565,
0.003604154, 0.002586031, 0.001934433, 0.002769293, 0.002952555,
0.004418652, 0.00431684, 0.003991041, 0.002667481, 0.002382407,
0.002810018, 0.002952555, 0.003115455, 0.003441254, 0.003726329,
0.00315618, 0.002138057, 0.002810018, 0.001954795, 0.002036245,
0.000468336, 0.002687844, 0.002586031, 0.002667481, 0.002647119,
0.003461617, 0.002911831, 0.000936673, 0.002875817, 0.004183007,
0.00496732, 0.00496732, 0.005490196, 0.003921569, 0.005228758,
0.006013072, 0.002614379, 0.002614379, 0.002352941, 0.002875817,
0.002614379, 0.003660131, 0.005490196, 0.002614379, 0.002091503,
0.001568627, 0.002352941, 0.002352941, 0.003921569, 0.00130719,
0.002614379, 0.00496732, 0.004183007, 0.002875817, 0.004183007,
0.003137255, 0.002614379, 0.002614379, 0.00130719, 0.000784314,
0.001830065, 0.003660131, 0.001830065, 0.003921569, 0.003660131,
0.001830065, 0.001830065, 0.002352941, 0.002875817, 0.002352941,
0.004444444, 0.002614379, 0.002352941, 0.002614379, 0.002875817,
0.004183007, 0.001830065, 0.002352941, 0.003921569, 0.003921569,
0.002614379, 0.002352941, 0.003660131, 0.002352941, 0.002875817,
0.002875817, 0.002352941, 0.002614379, 0.003137255, 0.002091503,
0.002352941, 0.001830065, 0.001045752, 0.002091503, 0.001045752,
0.000784314, 0.002614379, 0.001045752, 0.002614379, 0.001830065,
0.001830065, 0.003398693, 0.00130719, 0.001568627, 0.001045752,
0.002091503, 0.003660131, 0.000261438, 0.002875817, 0.001830065,
0.002091503, 0.001830065, 0.002091503, 0.001568627, 0.000784314,
0.001830065, 0.00130719, 0.003137255, 0.005490196, 0.002352941,
0.001830065, 0.002875817, 0.003921569, 0.003137255, 0.002614379,
0.001830065, 0.003921569, 0.002352941, 0.00130719, 0.002091503,
0.00130719, 0.003660131, 0.002091503, 0.002352941, 0.00130719,
0.000522876, 0.000522876, 0.001830065, 0.003137255, 0.00130719,
0.002352941, 0.003660131, 0.00130719, 0.002614379, 0.002352941,
0.002091503, 0.00130719, 0.001568627, 0.005228758, 0.002352941,
0.002352941, 0.001830065, 0.003660131, 0.001830065, 0.002352941,
0.003398693, 0.003137255, 0.001830065, 0.00130719, 0.002875817,
0.003137255, 0.003660131, 0.000522876, 0.003921569, 0.00130719,
0.003137255, 0.002352941, 0.002091503, 0.002091503, 0.002352941,
0.003137255, 0.001568627, 0.004444444, 0.002614379, 0.001568627,
0.00496732, 0.001830065, 0.00130719, 0.002352941, 0.004183007,
0.002875817, 0.001830065, 0.003137255, 0.003398693, 0.00130719,
0.00130719, 0.002352941, 0.00130719, 0.003398693, 0.002352941,
0.001830065, 0.002614379, 0.002875817, 0.002614379, 0.002091503,
0.004183007, 0.003921569, 0.005751634, 0.002875817, 0.002614379,
0.002875817, 0.005228758, 0.003398693, 0.002614379, 0.002875817,
0.003137255, 0.003921569, 0.004705882, 0.003921569, 0.004705882,
0.004444444, 0.005490196, 0.001045752, 0.002091503, 0.001830065,
0.002614379, 0.005490196, 0.001568627, 0.003137255, 0.005490196,
0.003921569, 0.003921569, 0.002352941, 0.003921569, 0.002614379,
0.003660131, 0.003921569, 0.003137255, 0.003137255, 0.001830065,
0.002091503, 0.004444444, 0.00496732, 0.004183007, 0.00130719,
0.001568627, 0.002875817, 0.003137255, 0.004705882, 0.005228758,
0.004705882, 0.003398693, 0.002352941, 0.001830065, 0.003660131,
0.004705882, 0.005228758, 0.004183007, 0.003398693, 0.003137255,
0.002352941, 0.001045752, 0.002875817, 0.003660131, 0.00130719,
0.006013072, 0.004705882, 0.002091503, 0.003398693, 0.008627451,
0.003660131, 0.002875817, 0.006013072, 0.001568627, 0.001830065,
0.002352941, 0.003398693, 0.002875817, 0.002091503, 0.003137255,
0.00130719, 0.003137255, 0.002091503, 0.002091503, 0.003398693,
0.002614379, 0.002614379, 0.00130719, 0.002614379, 0.002091503,
0.002352941, 0.003137255, 0.003398693, 0.002352941, 0.00130719,
0.001830065, 0.004183007, 0.002614379, 0.001830065, 0.004444444,
0.002352941, 0.001830065, 0.000784314, 0.002352941, 0.002875817,
0.002614379, 0.003137255, 0.002614379, 0.002091503, 0.001830065,
0.003137255, 0.002875817, 0.002875817, 0.00130719, 0.001568627,
0.002614379, 0.002614379, 0.002875817, 0.003398693, 0.002352941,
0.00130719, 0.001045752, 0.004705882, 0.001568627, 0.00130719,
0.00130719, 0.002091503, 0.001045752, 0.001830065, 0.000522876,
0.001830065, 0.002352941, 0.001568627, 0.001830065, 0.001045752,
0.00130719, 0.002614379, 0.00130719, 0.002091503, 0.000261438,
0.00130719, 0.002352941, 0.003921569, 0.001568627, 0.002091503,
0.001045752, 0.002091503, 0.001830065, 0.002352941, 0.00130719,
0.002875817, 0.001568627, 0.003921569, 0.002614379, 0.002875817,
0.001830065, 0.000522876, 0.002352941, 0.002352941, 0.00130719,
0.002875817, 0.003660131, 0.00130719, 0.000784314, 0.000784314,
0.001830065, 0.001045752, 0.002091503, 0.001568627, 0.00130719,
0.003921569, 0.002352941, 0.003660131, 0.002875817, 0.004183007,
0.005490196, 0.003660131, 0.003398693, 0.00130719, 0.002875817,
0.003137255, 0.003921569, 0.002614379, 0.002614379, 0.003660131,
0.002352941, 0.002614379, 0.00130719, 0.006535948, 0.004444444,
0.004705882, 0.002352941, 0.003660131, 0.00627451, 0.004183007,
0.002614379, 0.001045752, 0.002875817, 0.004183007, 0.002352941,
0.004705882, 0.006797386, 0.00496732, 0.001568627, 0.001834345,
0.000705517, 0.004091999, 0.00536193, 0.002963172, 0.003386482,
0.00536193, 0.005503034, 0.003668689, 0.004656413)), row.names = c(NA,
-742L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x000001c0111a1ef0>)
#Main operation that involves both tables
sw <- sw[StartDayOFYear<EndDayOFYear,RemRatio:=Sub_Index[as.numeric(sw[.I,StartDayOFYear]):as.numeric(sw[.I,EndDayOFYear]),sum(FailRatio)],by = ID]
sw <-
sw[StartDayOFYear > EndDayOFYear, RemRatio := Sub_Index[as.numeric(sw[.I, StartDayOFYear]):366, sum(FailRatio)] +
Sub_Index[1:as.numeric(sw[.I, EndDayOFYear]), sum(FailRatio)], by = ID]
sw <- sw[Functional_days == 365, RemRatio := 0.999]
sw = sw[is.na(RemRatio),RemRatio:=0]
As you can see from above, the last section which contain main operation, i performed this operation directly on the two input tables. But i need to run this operation on the individual sub-set tables and store the output on one main table.
Could you please advise
Thank you