首页 > 代码库 > 分享一个R语言的脚本【时间记录】
分享一个R语言的脚本【时间记录】
脚本就是把下面的这种excel文件导入并自动转化成饼形图,输出图片到本地。
代码在此:
record <- read.table("Book1.csv", header=TRUE,sep=",", fill=TRUE);
library(ggplot2);
new_sum<-na.omit(record$Sum);
rm(new_detail);
rm(detail);
new_detail <- na.omit(record$A);
start <- paste (record$Start, "-");
end <- record$End;
period <- paste (start, end);
hours <- record$x;
detail_sum <- paste(‘[‘, hours);
detail_sum <- paste(detail_sum, ‘]‘);
detail_sum <- paste(period, detail_sum);
detail<-paste(new_detail, detail_sum);
today <-Sys.Date();
today <- today -1 ;
today <- paste(today, weekdays(today));
qplot(detail, new_sum, geom="bar", xlab="things", ylab="time", stat="identity");
filename <- paste(today, ".bmp");
path <- "D:\\我的文档\\工具\\桌面\\";
path <- paste(path, filename);
bmp(path, width = 1600, height = 900);
pie(new_sum, detail, main=today, col.main="red", cex.main=2.6, radius=1, cex=1.5, edges=100, clockwise=TRUE, font=1);
dev.off();