I have a series of txt files I would like to plot in R, but I need help constructing a for loop to automate this for when I have dozens of files.
My current script, which is fine for a few files, is simply this two-line repetitive code:
data <- read.table("/path/filename1.txt")
plot(data, type = 'l', ylim=c(0,100), xlim = c(350,900))
data2 <- read.table("/path/filename2.txt")
points(data, type = 'l', ylim=c(0,100), xlim = c(350,900))
data3 <- read.table("/path/filename3.txt")
points(data, type = 'l', ylim=c(0,100), xlim = c(350,900))
data3 <- read.table("/path/filename3.txt")
points(data, type = 'l', ylim=c(0,100), xlim = c(350,900))
I am certain there is a simpler way to do this using a for loop, but I am unfamiliar with R and not sure how to accomplish this.
Thank you for the help!