绘制R中的波动

时间:2011-09-30 16:25:27

标签: r plot

我会尽量减少模糊。以下数据集包括设备的功率测量,我必须绘制一个图表,该图表显示时间列期间功率(瓦特)的平均波动。我必须在R中完成这个,但我真的不知道哪个功能或我应该怎么做,因为我是R的新手。任何帮助都将受到高度赞赏!

Store No.,Date,Time,Watt

33,2011/09/26,09:11:01,0.0599E+03

34,2011/09/26,09:11:02,0.0597E+03

35,2011/09/26,09:11:03,0.0598E+03

36,2011/09/26,09:11:04,0.0596E+03

37,2011/09/26,09:11:05,0.0593E+03

38,2011/09/26,09:11:06,0.0595E+03

39,2011/09/26,09:11:07,0.0595E+03

40,2011/09/26,09:11:08,0.0595E+03

41,2011/09/26,09:11:09,0.0591E+03

1 个答案:

答案 0 :(得分:0)

包中的

rollapply:zoo将返回移动平均线(或移动的任意函数)。您可以使用点进行绘图,然后添加移动平均线:

dat$D.time <- as.POSIXct(paste(dat$Date, dat$Time))
require(zoo)
 ?rollapply
 length(rollapply(dat$Watt,3, mean))
plot(dat$D.time, dat$Watt)
lines(dat$D.time[3:9], rollapply(dat$Watt,3, mean))