library(readr)
library(dplyr)
write.csv(wty,"C:/Users/kohei/Documents/R/eddp/WTY_data/wty_data.csv")
wty_data<-read_csv("c:/Users/kohei/Documents/R/eddp/WTY_data/wty_pick_data.csv")
#key,型,国,Year,登録日,番号1,2,3,4,コード
pick_col<-c("UNI_KEY_ORI","FR_CD","Cont_CD","MY_CD","REP_DO_DATE","PN_5","PN_3_1","PN_3_2","PN_EX","SY_CD_1","SY_CD_2")
wty_pick_data<-wty_data[,pick_col]
#日付型変更
wty_pick_table_data$$REP_DO_DATE <- as.POSIXct(strptime(as.character(wty_pick_table_data$REP_DO_DATE), format="%Y%m%d"))
#番号連結
wty_pick_table_data<-wty_pick_data %>% as.data.frame() %>% mutate(parts_code = paste(!!!rlang::syms(c("PN_5","PN_3_1","PN_3_2","PN_EX")), sep="-"))
#集計
wty_table<-data.frame(table(wty_pick_table_data$$MY_CD,wty_pick_table_data$Cont_CD,wty_pick_table_data$FR_CD,wty_pick_table_data$parts_code))
wty_table<-wty_table[order(wty_table$Freq,decreasing = T),]
#累積
parts_list<-unique(wty_table$$Var4)
pick_parts<-parts_list[1]
FR_CD_data<-""
Cont_CD_data<-""
MY_CD_data<-""
wty_parts_table<-wty_pick_data[wty_pick_table_data$parts_code==pick_parts&wty_pick_table_data$FR_CD==FR_CD_data&wty_pick_table_data$Cont_CD==Cont_CD_data&wty_pick_table_data$MY_CD==MY_CD_data,]
acc_table<-data.frame(table(wty_parts_table$REP_DO_DATE))
acc_table$Var1 <- as.POSIXct(strptime(as.character(acc_table$Var1), format="%Y%m%d"))
write.csv(acc_table,"c:/Users/kohei/Documents/R/eddp/WTY_data/acc_table.csv")