给自己保留的。。。。如果你无意中看到,希望对你有用
library(RMySQL)
library(ggplot2)conn<-dbConnect(MySQL(),group='kettle')
sql<-"select * from eslPower";
stmt<-dbSendQuery(conn,sql)
mydata<-fetch(stmt,n=-1)
things_id<-mydata[,'things_id']
things_id<-things_id[!duplicated(things_id)]
showpictureInggplot2<-function(x){
dataESL<-mydata[mydata[,'things_id']==things_id[x],]
dataESL<-dataESL[,c('work_time','power')]
dataESL<-dataESL[!duplicated(dataESL[,'power']),]
ggplot(aes(x=work_time,y=power),data=dataESL)+geom_point()+theme(axis.text.x=element_text(angle=-90,size=8))
ggsave(filename=paste("Rplog",x,".jpeg",sep=""),width=10,height=10,units="cm")
}
showpictureInDotChat<-function(x){
dataESL<-mydata[mydata[,'things_id']==things_id[x],]
dataESL<-dataESL[,c('work_time','power')]
dataESL<-dataESL[!duplicated(dataESL[,'power']),]
power<-dataESL[,'power']
time<-dataESL[,'work_time']
names(power)<-dataESL[,'work_time']
jpeg(filename=paste("dotchart",x,".jpeg",sep=""),width=480,heigh=400,units="px",pointsize=12,quality=75,bg="white")
dotchart(power,cex=0.7)
dev.off()
}
for(i in 1:150){
showpictureInggplot2(i)
}
showpictureInggplot2(1)
showpictureInDotChat(2)