In <- read.table("sequence1.txt") Out <- read.table("sequence1.data") Out1 <- Out[,c(2,4,6,8,10,12,14)] Out2 <- Out[,c(3,5,7,9,11,13,15)] # X <- apply(Out2,2,mean) png(filename="Sequence%d.png",width=600,height=600) plot(1:7,X, main="3+4 digit strings: overall duration by position", xlab="Position", ylab="Mean duration in seconds (of 100)", type="b", pch="x") X1 <- matrix(ncol=7,nrow=10) for(d in 0:9){ for(p in 1:7){ rows <- (In[,p]==d) X1[d+1,p] <- mean(Out2[rows,p]) } } plot(1:7,X1[1,], main="3+4 digit strings: duration by position\n(Individual digit types)", xlab="Position", ylab="Mean duration in seconds (of 10)", ylim=range(X1), type="b", pch="0", col="red") mylines <- c(2,3,4,5,6,5,4,3,2) mycolors <- c("blue", "green", "black", "sienna", "rosybrown", "turquoise", "sandybrown", "orange", "olivedrab", "violetred") for(d in 1:9){ points(1:7,X1[d+1,], type="b", pch=toString(d), lty=mylines[d], col=mycolors[d]) }