分享一个R语言的脚本【时间记要】

分享一个R语言的脚本【时间记录】
分享一个R语言的脚本
 最近捣弄下一个R语言的脚本,不知道大家有没有看过《奇特的一生》这本书,我高中看了后,高三就山寨了柳比歇夫大神的方法,记录时间开销。个人感觉是挺有用的。

脚本就是把下面的这种excel文件导入并自动转化成饼形图,输出图片到本地。

 

 分享一个R语言的脚本【时间记要】

分享一个R语言的脚本【时间记要】






代码在此:

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();