本文章内包含日常学习和工作中收集的代码,接下来我也会不断的补充,有需要的小伙伴自取。
1. 数据批量筛选
fData = data[data$brand%in%c("GREE","Erie","Huawei"),]
#抽取商品标题包含关键词“平板”的商品数据记录
fData = data[grepl('Huawei',data$title),]
#组合提取
fData = data[
(data$comments>=1000)
&(data$comments<=10000)
&(data$brand =='Huawei'),
]
2.变量因子化
my_da[,age_cut:=cut(age,breaks = c(0,5,15,20,25,30,35,40,45,50,55,60,65,70,75,80),
right = F,include.lowest = T)]
3.分组统计描述
summary.stat.char <- function(data=NULL, measurevar, groupvars=NULL, na.rm=TRUE,
conf.interva