0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【R】 基礎データ抽出

Posted at

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")

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?