I want to plot several files in the same figure; each file has two-column data.
The problem is that each file has a different number of rows (529,567,660, etc)
For data with same number of rows I did the following:
data1 <- read.table(file="ro0.2/T0.1/sq_Ave.dat")
x1 <- data1[1]
y1 <- data1[2]
data2 <- read.table(file="ro0.4/T0.1/sq_Ave.dat")
x2 <- data2[1]
y2 <- data2[2]
max_valuex = max(x1,x2,x3,x4,x5)
max_valuey = max(y1,y2,y3,y4,y5)
matplot(x1,cbind(y1,y2,y3,y4,y5),type="l",
col=c("black","red","green","blue","orange"),
lwd = 2,xlab = expression(q*sigma), ylab="S(q)", col.lab="black",
cex.lab=1.5,font.lab=4, xaxt = "n", yaxt = "n", xlim = c(0,max_valuex),
ylim = c(0,max_valuey), xaxs = "i", yaxs = "i")
However, this does not work for files with different number of rows.
R complains with:
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 529, 567, 661
Calls: matplot -> ncol -> as.matrix -> cbind -> cbind -> data.frame
Any idea or suggestion would be greatly appreciated!
Thanks a lot in advance
S H-V