Adding lines to my graph

I'm confused about where am I supposed to put the data files. I renamed the CSV files to DATA-001.csv etc. and placed in C:\GCDC. Is that correct?

I believe your code creates plot separately for the three variables. I'm not sure, though.

If you want to plot the multiple line diagram in Line 344: output<-array(c(x.axis, fftHistory), dim=c(length(x.axis),2)), you can have three outputs corresponding to dataX, dataY and dataZ (changing accordingly in Line 279), and then use:

# outputX is obtained in Line 343 using data<-dataX in Line 279
plot(outputX, 
     type="l", 
     tck=1, 
     xlab="Frequency (Hz)", 
     ylab="RMS Acceleration", 
     xlim=c(0,SR/2), 
     ylim=c(0,max(fftHistory[5:length(fftHistory)])), 
     main=dataFiles[1])

# outputY is obtained in Line 343 using data<-dataY in Line 279
plot(outputY, 
     type="l", 
     tck=1, 
     xlab="Frequency (Hz)", 
     ylab="RMS Acceleration", 
     xlim=c(0,SR/2), 
     ylim=c(0,max(fftHistory[5:length(fftHistory)])), 
     main=dataFiles[1])

# outputZ is obtained in Line 343 using data<-dataZ in Line 279
plot(outputZ, 
     type="l", 
     tck=1, 
     xlab="Frequency (Hz)", 
     ylab="RMS Acceleration", 
     xlim=c(0,SR/2), 
     ylim=c(0,max(fftHistory[5:length(fftHistory)])), 
     main=dataFiles[1])

############################################################

output_column1 <- cbind(outputX[,1],outputY[,1],outputZ[,1])
output_column2 <- cbind(outputX[,2],outputY[,2],outputZ[,2])

matplot(x = output_column1,
        y = output_column2,
        type = "l",
        lty = c(1, 3, 4),
        lwd = c(1, 1, 2),
        col = 1,
        tck=1,
        xlab = "Frequency (Hz)",
        ylab = "RMS Acceleration",
        xlim = c(0, SR/2),
        ylim = c(0, max(fftHistory[5:length(fftHistory)])),
        main = dataFiles[1])
legend("topright",
       legend = c("outputX", "outputY", "outputZ"),
       col = 1,
       lty = c(1, 3, 4),
       lwd = c(1, 1, 2))

This will yield the following:

Does this help?

This is unexpected. Which line creates this error?

What about rect?