Plotting huge data files in R?

前端 未结 5 747
独厮守ぢ
独厮守ぢ 2021-02-09 00:54

I have a input file that has about 20 million lines. The size of the file is about 1.2 G. Is there anyway I can plot the data in R. Some of the columns have categories, most

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-09 01:43

    plotting directly into a raster file device (calling png() for instance) is a lot faster. I tried plotting rnorm(100000) and on my laptop X11 cairo plot took 2.723 seconds, while png device finished in 2.001 seconds. with 1 million points, the numbers are 27.095 and 19.954 seconds.

    I use Fedora Linux and here is the code.

    f = function(n){
    x = rnorm(n)
    y = rnorm(n)
    png('test.png')
    plot(x, y)
    dev.off()}
    
    g = function(n){
    x = rnorm(n)
    y = rnorm(n)
    plot(x, y)}
    
    system.time(f(100000))
    system.time(g(100000))
    

提交回复
热议问题