-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_preparing_huo.R
89 lines (69 loc) · 1.89 KB
/
data_preparing_huo.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
setwd('/mnt/e/R')
getwd()
rm(list=ls()) ##
ls()
gc()
library(dplyr)
library(stringr)
library(readr)
library(data.table)
library(ggplot2)
q()
#========================常用包==================================#
library(dplyr)
library(stringr)
library(feather)
library(readr)
library(data.table)
library(plyr)
library(reshape2)
library(devtools)
library(grid)
library(Rcpp)
library(nortest)
library(qcc)
library(randomForest)
library(rpart)
library(rattle)
library(rpart.plot)
library(RColorBrewer)
library(party)
library(car)
library(ipred)
#=======================常用包安装===============================#
install.packages('dplyr')
install.packages('plyr')
install.packages("data.table")
install.packages("stringr")
install.packages("readr")
install.packages('ggplot2')
install.packages('feather-format')
install.packages("car")
install.packages('nortest')
install.packages("devtools")
devtools::install_github("wesm/feather/R")
install.packages('qcc')
install.packages('rpart')
install.packages('rpart.plot')
install.packages("rattle")
install.packages("RColorBrewer")
install.packages("randomForest")
install.packages("party")
install.packages("ipred")
tbl_cpdata<-tbl_df(cpdata)
tbl_cpdata
##删除不必要列
tbl_cpdata<-select(tbl_cpdata,-age60,-(id:opertms7))
cpdata<-within(cpdata,
disctype[is.na(disctype)] <-"其他" ##补充完整disctype 26个缺失值
)
sum(is.na(cpdata$disctype)) ##补充完成
str(cpdata$disctype)
data_all<-tbl_df(r0913)
data_all
ab_opdays<-select(data_all,recordcode,address,b_opdays,a_opdays)
ab_opdays
tbl_cpdata<-merge(tbl_cpdata,ab_opdays,by="recordcode")
tbl_cpdata<-tbl_df(tbl_cpdata)
tbl_cpdata
save(list=ls(),file='cpdata1201.Rdata')