I have a dataframe with 1104 rows and 2 columns
a<-rep(1998:2013,times=69)
b<-rnorm(1104)
data<-data.frame(a,b)
What I am trying to do is plot the first 48 rows in the following fashion:
plot(data$b[1:16] ~ data$a[1:16],col="red")
points(data$b[17:32] ~ data$a[17:32],col="green")
points(data$b[33:48] ~ data$a[33:48],col="blue")
This will give me a graph with three sets of data on it. Then I want to repeat this for the next set of 48 rows, something like this:
plot(data$b[49:64] ~ data$a[1:16])
points(data$b[65:80] ~ data$a[65:80])
points(data$b[81:96] ~ data$a[81:96])
And I want to keep repeating it till the 1104th row
plot(data$b[1057:1072] ~ data$a[1057:1072])
points(data$b[1073:1088] ~ data$a[1073:1088])
points(data$b[1089:1104] ~ data$a[1089:1104])
Is there any way I can put this in a loop? This implies that I will have 23 plots.
Thank you for your help.
data$a[1:16], where you wanting to stack all of the data points? Do you have an image of a desired output (or something similar)? Also your limits access 2 different datasets, is that intentional (min of a, max of b)?pointsare outside of plot and they are not being plotted. What is the desired output?