> 每天的总结prod_sumy1= rawdata_vi_prod[,c(2,8)]
prod_sumy2 = count(prod_sumy1, c("inrt_date", "prodID"))
prod_sumy3 = count(prod_sumy1, "prodID")
夏荔芪胶囊
head(prod_sumy2)回头太难歌词
prod1 = merge(prod_sumy2,rawdata_pd[,c(1,4,5,31)],by.x = "prodID", by.y = "ID",all.x=T)
head(prod1)
daily_prod_rank = prod1[with(prod1, order(-as.numeric(inrt_date),-freq)),]什么是海啸
names(daily_prod_rank)[c(1,2,3)] <- c("ProdId","InrtDate","PVCnt")英国历史时间轴
head(daily_prod_rank)
daily_prod_rank$InrtDate = as.character(daily_prod_rank$InrtDate)
### 导⼊到数据库
conn <- dbConnect(MySQL(), dbname = "analy", urname="gaoyang922", password="gaoyang922@123456!",host="10.10.109.62",port=1333) dbWriteTable(conn, "daily_prod_rank_raw", prod_sumy2)
### 产品1.关注,2.购买,3.预约,4.点赞
conn <- dbConnect(MySQL(), dbname = "pms", urname="gaoyang922", password="gaoyang922@123456!",host="10.10.109.62",port=1333)
query<-dbSendQuery(conn, "SELECT productID,RelationType,
(ca when RelationType=1 then '关注'
when RelationType=2 then '购买'
when RelationType=4 then '点赞'
el '预约' end
)as RT_desc
,count(*) as pd_cnt FROM pms.pms_ur_relation
where CreateTime between '2015-08-18' and '2015-09-05'
group by ProductId,RelationType ")
rawdata_RT <- fetch(query,n=-1)
dbDisconnect(conn)
head(rawdata_RT)
table(prodID)
prodID_ggplot<-rawdata_vi$prodID;prodID_ggplot<-reorder(prodID_ggplot,prodID_ggplot,length)
rawdata_vi$prodID_ggplot<-prodIDe_ggplot
ggplot(subt(rawdata_vi,prodID!=9999),aes(x=prodID_ggplot))+geom_bar()
#
# library(ggplot2)
# library(RMySQL)
# library(stringr)
# library(dplyr)
# conn <- dbConnect(MySQL(), dbname = "tracker", urname="zhoumeixu204", password="zhoumeixu204@123456!",host="10.10.109.62",port=1333) # query<-dbSendQuery(conn, "SELECT key_table,left(inrt_time,8) as
# inrt_date,label,ssionid,stay_time,site,page_url FROM tracker.hba_visit
# where inrt_time is not null ")
#
#
# query_1<-dbSendQuery(conn,"
# lect * from tracker.hba_visitor where inrt_time
# is not NULL and city is not NUll and country='china'")
# rawdata_vi <- fetch(query,n=-1)
# hba_visitor<-fetch(query_1,n=-1)
# dbDisconnect(conn)
# head(rawdata_vi)
# f<-function(x){
# if(grepl("productId",x)){
# result<-as.numeric(unlist(str_extract_all(x,"[0-9]{1,2}"))[1])
#
# }
# el{
# result<-9999
# }
# result
# }
红葫芦# rawdata_vi$prodID =sapply(rawdata_vi$page_url,f)
# # rawdata_vi<-subt(rawdata_vi,prodID!=9999)
# table(prodID)
#
#
# prodID_ggplot<-rawdata_vi$prodID;prodID_ggplot<-reorder(prodID_ggplot,prodID_ggplot,length)
# rawdata_vi$prodID_ggplot<-prodID_ggplot
# site_ggplot<-rawdata_vi$site;site_ggplot<-reorder(site_ggplot,site_ggplot,length)
# rawdata_vi$site_ggplot<-site_ggplot
# ggplot(subt(rawdata_vi,prodID!=9999),aes(x=prodID_ggplot))+geom_bar(aes(fill=prodID_ggplot))
# ggplot(subt(rawdata_vi,prodID!=9999),aes(x=prodID_ggplot,fill=factor(inrt_date)))+geom_bar(position = 'stack')+labs(title="移动终端占⽐柱形图")
直言直语
# ggplot(rawdata_vi,aes(x=site_ggplot,fill=factor(inrt_date)))+geom_bar(position = 'dodge')+labs(title="移动终端占⽐柱形图")
形容冰雪的成语# ggplot(rawdata_vi,aes(x=site_ggplot,fill=factor(inrt_date)))+geom_bar(position = 'stack')+labs(title="移动终端占⽐柱形图")
# ggplot(rawdata_vi,aes(x=site_ggplot,fill=factor(inrt_date)))+geom_bar(position = 'dodge')+labs(title="移动终端占⽐柱形图")+facet_wrap(~inrt_date,ncol=1) # str(rawdata_vi)
# rawdata_vi_to_mysql<-data.frame(rawdata_vi$key_table,rawdata_vi$inrt_date,rawdata_vi$label,rawdata_vi$ssionid,rawdata_vi$stay_time,rawdata_vi$site # conn <- dbConnect(MySQL(), dbname = "analy_dev", urname="root", password="Pa123456!",host="202.69.27.239",port=8443)
# rawdata_vi_to_mysql<-subt(rawdata_vi_to_mysql,rawdata_vi.prodID !=9999)
# dbWriteTable(conn, "rawdata_vi_to_mysql", rawdata_vi_to_mysql)
# dbDisconnect(conn)
#
#