Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df %<>% distinct(notificationNumber, lot_id, product_id, .keep_all = TRUE)
- df$okpd2 %<>% as.factor
- df %<>%
- mutate(
- etp = ifelse(is.na(etp), "unknown", etp),
- okpd2_head = substr(okpd2, 1, 2),
- okpd2_group = substr(okpd2, 1, 5),
- okpd2_type = substr(okpd2, 1, 8)
- )
- count_lot <- df %>%
- group_by(lot_id) %>%
- summarise(count = n_distinct(product_id))
- df %<>%
- group_by(lot_id) %>%
- mutate(
- main_okpd2_class = MaxTable(okpd2_head),
- main_okpd2_group = MaxTable(okpd2_group),
- main_okpd2_type = MaxTable(okpd2_type),
- main_okpd2_subcat = MaxTable(okpd2)
- ) %>% ungroup()
- df %<>% left_join(count_lot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement