Plotting Simple Data in R

后端 未结 7 1637
旧时难觅i
旧时难觅i 2021-02-01 06:28

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         


        
7条回答
  •  无人共我
    2021-02-01 06:55

    In your example,

    plot(scale, serial) 
    

    won't work because scale and serial are both data frames, e.g.

    class(scale)
    [1] "data.frame"
    

    You could try the following and use points(), once the plot has been generated, to plot the remaining columns. Note, I used the ylim parameter in plot to accommodate the range in the third column.

    data <- read.csv('foo.csv', header=T)
    plot(data$scale, data$serial, ylim=c(0,750))
    points(data$scale, data$spawn, col='red')
    points(data$scale, data$for., col='green')
    points(data$scale, data$worker, col='blue')
    

提交回复
热议问题