0

我已经能够根据以下数据生成多条线图。

数据样本

这是代码片段(我很抱歉,但我的代码与这篇文章的格式不匹配,所以我将片段添加为图像)。

for(i in 1:1){
speedpath = file.path("C:",paste("yspeedplot_",format(Sys.time(), "%Y-%m-%d %Hh%Mm%Ss"), ".png", sep = ""))
png(file=speedpath, width=(framewidthx*2), height=(frameheighty*2), units="px", bg = "white",res=300)

xrange=range(Timestamp_num)
yrange=range(boundy)
mytitle = paste("People Y-Speeds_",format(Sys.time(), "%Y-%m-%d %H:%M:%S"))
plot(Timestamp_num, boundy, type="n", yaxt = "n",main=mytitle, xlab="Time Stamp", ylab="Y location",
   xlim=c(0,max_time),ylim=c(0,frameheighty))
axis(side = 2, at = yticks, labels = yticks)
colors=rainbow(number_people, alpha=colorsalp)
linetype=c(1:number_people)
plotchar = seq(18,18+number_people,1)

for (i in 1:length(unique(PersonID_Num))) {
lines(Timestamp_num[PersonID_Num==unique(PersonID_Num)[i]], 
      boundy[PersonID_Num==unique(PersonID_Num)[i]], type = "b", lwd = 1.5, lty = linetype[i], col = colors[i], pch=16)
}
dev.off()

}

这为我产生了以下情节。

速度图

我希望能够为每条绘图线导出趋势线斜率。然后我想计算所有绘图线的平均趋势线斜率。我该怎么做呢?

4

0 回答 0