什么硬件限制了R的绘制速度? [英] What hardware limits plotting speed in R?

查看:126
本文介绍了什么硬件限制了R的绘制速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提高绘图的速度,并且对R图形和ggplot软件包感到满意(并且有很多代码需要) - 所以我只想知道如何配置我的系统来加速绘图。特别是:


  1. R处理速度受处理器限制,内存,显卡?

  2. 是否有特定的硬件组件或配置会提高绘图速度?






更新:在评论中回答问题:

规格:Ubuntu 11.04,英特尔酷睿双核,8GB内存,但我更感兴趣的是图形计算或图形渲染是有限的,如果是这样,我该如何使用这些信息。



我的图有很多对象,但我不知道绘图的计算成本是。在绘图时(我在完成任何必要的分析后绘制图表),我没有做任何具体分析,尽管我知道有些是在飞行中完成的,就像绘制平滑线或将数据转换成位置一样。

解决方案

除非您有计算机密集型单图,否则加速多重绘图的好方法是采用并行处理。例如,假设你有一个数据框,并且你想用某个变量(或多个变量)对其进行分解,并为每个分区做图。

有很多方法注册一个并行后端,所以我不会进入。例如,请参阅此小插图: http://cran.r -project.org/web/packages/doSMP/vignettes/gettingstartedSMP.pdf



然后检查 ddply 在Hadley的 plyr 包中,并使用 .parallel = TRUE 选项。基本上就是这样。



以下是一个独立的示例:

 #这是我选择注册并行后端的特定库。还有其他人。有关详细信息,请参阅新的Parallel R书。 
library(doMC)
registerDoMC()
getDoParWorkers()#This列出了你有多少工人(希望超过1!)

library(ggplot2)
ddply(
mtcars,.variables =vs,.fun = function(x){
#现在绘图
example_plot< - ggplot(x,aes(y (x = vs [1],。pdf,sep =mpg,x = wt))+ geom_point()+ geom_smooth(se = FALSE)
#save your plot
ggsave ),example_plot)
},
.parallel = TRUE

这将保存两个文件,0.pdf和1.pdf,它们是<$ c $ 和变量的级别(即唯一值) c> mtcars dataframe。如果你用变量 country name 分解它,那么保存的文件将是这些国家的名称。 0.pdf和1.pdf如下:




I would like to increase the speed of plotting, and I am happy with (and have lots of code requiring) the R graphics and ggplot packages - so I am only interested in knowing how I can configure my system to speed up plotting.

Specifically:

  1. Is the speed of plotting in R limited by the processor, memory, graphics card?
  2. Are there particular hardware components or configurations would increase plotting speed?


Update: Answers to questions in comments:

specs: Ubuntu 11.04, intel Core Duo, 8GB ram, but I am more generally interested in wether the graphical computation or the graphical rendering is limiting, and if so, how can I use this information.

My plots have lots of objects, but I have no idea what the computational costs of plotting is. I don't do any specific analyses while plotting (I am plotting after completing any required analyses), although I understand that some is done 'on the fly', as when plotting a smoothed line or even translating data into locations.

解决方案

Unless you have computer-intensive single plots, a great way to speed up multiple plotting is with parallel processing. For example, suppose you have a dataframe and you want to break it down by a certain variable (or variables) and do plots for each partition.

There are many ways to register a parallel backend so I won't go into that. See, for example, this vignette: http://cran.r-project.org/web/packages/doSMP/vignettes/gettingstartedSMP.pdf

Then check out the function ddply in Hadley's plyr package and use the .parallel = TRUE option. That's basically it. Then just do plotting normally.

Here's a self-contained example:

#this is the particular library I chose to register a parallel backend. There are others. See the new "Parallel R" book for details.
library(doMC)
registerDoMC()
getDoParWorkers() #This lists how many workers you have (hopefully more than 1!)

library(ggplot2)
ddply(
        mtcars, .variables = "vs", .fun = function(x) {
        #do your plotting now 
        example_plot <- ggplot(x, aes(y = mpg, x = wt)) + geom_point() + geom_smooth(se = FALSE)
        #save your plot
        ggsave(paste(x$vs[1],".pdf",sep = ""), example_plot)
        },
        .parallel = TRUE
)

This will save two files, 0.pdf and 1.pdf, which are the levels (ie the unique values) of the vs variable of the mtcars dataframe. If you broke it down by a variable country name then the files saved would be the names of the countries. 0.pdf and 1.pdf are as below:

这篇关于什么硬件限制了R的绘制速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆