I apologies in advance if this question has already been answered but I have not been able to find what I need. I want to plot some results from files named data1.dat, data2.dat, ... I manage to import the data with a loop but I am unable to plot the results using a loop. Only the results from the first data is ploted. Below is the script that I used:
for(i in 1:3){
assign( paste("data", i, sep=""),
read.table(file=paste(paste("data", i, sep=""),"_lambda.dat",sep=""),head=TRUE, sep=" "))
}
#plot
for(i in 1:3){
if(i==1){
plot(data.frame(data1[1], data1[2]), xlim=c(-0.2, -7), ylim=c(0.31, 0.35), yaxt="n", type="l", xlab="", ylab="",lty="solid", col="red2", lwd=4, axes=TRUE)
} else {
lines(data.frame(paste("data", i, "[1]", sep=""), paste("data", i, "[2]", sep="")) ,lty="twodash", col="deepskyblue4", lwd=4)
}
}
The problem is related to the part after the "else". The data is not ploted and I don't get any error message either.
Thanks for the help,