for brad ## .............. This is how bad the problem is ................................ ## OFFENSES BY CONTINENT minDateChecking <- as.Date("2014-01-01") DT.label_count_by_country <- DT.merge.bak[, list(has_o=any(upc_has_at_least_one_infrac & latest_infrac_by_label >= minDateChecking)), by=list(label_country, label_sc_group, labelid) ][, list(total_labels=.N, offending_labels=sum(has_o), perc_of_total_labels=percTrue(has_o)), by=list(supply_chain=label_sc_group, label_country)][order(perc_of_total_labels, decreasing=TRUE)][, perc_of_total_labels := fwp(perc_of_total_labels)] DT.label_count_by_country <- DT.label_count_by_country[offending_labels > 2][order(supply_chain, decreasing=TRUE)] ## The number of labels for which there is hidden content ## Double check the code here DT.merge.bak[, lunique(labelid), keyby=list(year(latest_infrac_by_label), month(latest_infrac_by_label))] ## .............. This is how bad the problem is ................................ latest_infrac_by_upc year_of_latest_infraction_by_upc extract("label", DT.merge.bak) %>% pasteQ kCols.labelmeta <- c('label_sc_group', 'label_owner', 'label_is_dthree', 'label_is_ioda', 'label_country', 'label_continent', 'label_is_o_and_o', 'label_priority', 'label_client_manager', 'labelid', 'label_name', 'label_has_at_least_one_infrac', 'imprint', 'lifetime_infracs_by_label', 'lifetime_infracting_upcs_by_label', 'latest_infrac_by_label') DT.infracs_by_label <- DT.merge.bak[, list( has_infraction_in_2014=any(upc_has_at_least_one_infrac & year_of_latest_infraction_by_upc == 2014) , has_infraction_in_2015=any(upc_has_at_least_one_infrac & year_of_latest_infraction_by_upc == 2015) , has_infraction_in_2016=any(upc_has_at_least_one_infrac & year_of_latest_infraction_by_upc == 2016) , latest_infraction = if (all(is.na(latest_infrac_by_upc))) as.Date(NA) else maxn(latest_infrac_by_upc) ), by=kCols.labelmeta] DT.infracs_by_label[, identical(latest_infraction, latest_infrac_by_label)] DT.infracs_by_label[(latest_infraction != latest_infrac_by_label)] DT.hidden[label_name == "Jober Entertainment", sumn(lifetime_infracs_by_apid)] DT.hidden[label_name == "Jober Entertainment", lunique(upcs)] / 2274 DT.merge.bak[label_name == "Jober Entertainment", lifetime_infracs_by_label] DT.infracs_by_label[label_name == "Jober Entertainment"]