I have a comma separated file named foo.csv containing the following data:
scale, serial, spawn, for, worker
5, 0.000178, 0.000288, 0.000292, 0.0003
You don't need the two lines:
scale <- data[1]
serial <- data[2]
as scale and serial are already set from the headers in the read.table.
Also scale <- data[1] creates an element from a data.frame
data[1]
1 5
2 10
3 12
4 15
whereas scale from the read.table is a vector
5 10 12 15
and the plot(scale, serial) function expects vector rather than a data.frame, so you just need to do
plot(scale, serial)
One approach to plotting the other columns of data on the y-axis:
plot(scale,serial, ylab="")
par(new=TRUE)
plot(scale,spawn,axes=F, ylab="", type="b")
par(new=TRUE)
plot(scale,for., axes=F, ylab="", type="b")
par(new=TRUE)
plot(scale,worker,axes=F, ylab="", type="b")
There are probably better ways of doing this, but that is beyond my current R knowledge....