I am new to r and hope to get some help with using a loop function to create graphs.
I hope to create 288 graphs, and the data are in stacked format. Each graph is created from 30 rows of data, so in total I have 288*30 = 8640 rows in my data.
I managed to create a first graph using this code-
# setting range and table
xrange <- range(0,300)
yrange <- range(1,15)
plot(xrange, yrange, type="n", xlab="Time in seconds", ylab="Performance")
# adding lines
lines(df$TimeStamp0[1:30],df$Pur[1:30], type="o", pch=4, col="red")
lines(df$TimeStamp0[1:30],df$Yel[1:30], type="o", pch=4, col="blue")
lines(df$PartTimeStamp0[1:30],df$PartPur[1:30], type="o", pch=20, col="green")
lines(df$PartTimeStamp0[1:30],df$PartYel[1:30], type="o", pch=20, col="orange")
There are four lines for four different performance components. I hope to create a loop to get this syntax to generate a graph every 30 rows through my entire dataset. I tried the "for loop" command (see below) but couldn't get it to work.
for(i in 1:288) {
startRow=1, endRow=startRow+29
#pasted the above graph creation syntax
}
I would really appreciate any help, thanks!!
[1:30]to[startRow:endRow]