boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 请教:如何能加速R codes 运行?
相关主题
【欢迎进来讨论】for loop in R
问个R里面avoid for loop的问题(sapply,lapply...)
问个R的问题
sas simulation big dataset problem
[合集] SAS的问题
R LOOP自动退出的问题
如何用DATAFRAME里的数字作为参数去产生随即数做SIMULATION
请教一个R的问题(function)
R 里面怎样记录程序的运行时间 ??
弱问一个R的问题
相关话题的讨论汇总
话题: codes话题: package话题: lot话题: rewrite话题: 运行
进入Statistics版参与讨论
1 (共1页)
j*********n
发帖数: 35
1
我写了几行简单的simulation codes,但是发现运行的具慢无比。
不知道有没有什么办法能加速运行。
另外有没有DX知道如何将tar.gz package 安装到windows R上。
谢谢了。
g**********t
发帖数: 475
2
There is no simple way to make it faster. You need to figure out why it is
slow and then optimize your code or rewrite the time consuming functions in
C.
j*********n
发帖数: 35
3
Thanks a lot for your input. I don't have C installed so it might not be
easy for me to rewrite the time consuming functions.
Have you tried to use parallel run package in R? Any recommendation on that
and will this type of package help?
Thanks.

in

【在 g**********t 的大作中提到】
: There is no simple way to make it faster. You need to figure out why it is
: slow and then optimize your code or rewrite the time consuming functions in
: C.

d*******e
发帖数: 1649
4
R做simulation肯定很慢,这不是它的长处所在。

【在 j*********n 的大作中提到】
: 我写了几行简单的simulation codes,但是发现运行的具慢无比。
: 不知道有没有什么办法能加速运行。
: 另外有没有DX知道如何将tar.gz package 安装到windows R上。
: 谢谢了。

h**********1
发帖数: 155
5
这个问题好像是老生常谈了
有几个注意的点啊
1. vectorize your code.
some designated R functions are much more faster than R for loop even though
they can achieve the same functionality.
2. profile your code.
by this way you can identity which pieces of your R code take the most
computational time.
for those computationally intense code, rewrite it in C. and call it within
R.
3. try parallel computing.
a lot of packages can do this. just need to configure your system properly.
Plus, it's easier to do in under linux than under Win.

【在 j*********n 的大作中提到】
: 我写了几行简单的simulation codes,但是发现运行的具慢无比。
: 不知道有没有什么办法能加速运行。
: 另外有没有DX知道如何将tar.gz package 安装到windows R上。
: 谢谢了。

j*********n
发帖数: 35
6
Thanks a lot for the response.
Have tried step 1,2. I would like to try the 3rd way suggested by you.
But found most of the parallel run package is tar.gz file.
Is there any .zip package I can use?
Thanks.

though
within

【在 h**********1 的大作中提到】
: 这个问题好像是老生常谈了
: 有几个注意的点啊
: 1. vectorize your code.
: some designated R functions are much more faster than R for loop even though
: they can achieve the same functionality.
: 2. profile your code.
: by this way you can identity which pieces of your R code take the most
: computational time.
: for those computationally intense code, rewrite it in C. and call it within
: R.

a***d
发帖数: 336
7
do you have a lot of 'for' loops in the simulation? replace those with '
sapply' will speed things up greatly.

【在 j*********n 的大作中提到】
: 我写了几行简单的simulation codes,但是发现运行的具慢无比。
: 不知道有没有什么办法能加速运行。
: 另外有没有DX知道如何将tar.gz package 安装到windows R上。
: 谢谢了。

h**********1
发帖数: 155
8
what's the system you are using?
if linux, use tar to uncompress
if windows, then check this
http://cran.r-project.org/web/views/HighPerformanceComputing.ht
they all have .zip file

【在 j*********n 的大作中提到】
: Thanks a lot for the response.
: Have tried step 1,2. I would like to try the 3rd way suggested by you.
: But found most of the parallel run package is tar.gz file.
: Is there any .zip package I can use?
: Thanks.
:
: though
: within

j*********n
发帖数: 35
9
Thanks a lot. I will search on the link.

【在 h**********1 的大作中提到】
: what's the system you are using?
: if linux, use tar to uncompress
: if windows, then check this
: http://cran.r-project.org/web/views/HighPerformanceComputing.ht
: they all have .zip file

j*********n
发帖数: 35
10
I did have a loop in codes. After simplifying the codes and applying apply()
, the speed was improved about 15%.
Thanks.

【在 a***d 的大作中提到】
: do you have a lot of 'for' loops in the simulation? replace those with '
: sapply' will speed things up greatly.

c*****l
发帖数: 1493
11
apply在内存上有节省,但是不如上面的sapply
不过我也不会用sapply。。。。

()

【在 j*********n 的大作中提到】
: I did have a loop in codes. After simplifying the codes and applying apply()
: , the speed was improved about 15%.
: Thanks.

r********0
发帖数: 65
12
赞一个

though
within

【在 h**********1 的大作中提到】
: 这个问题好像是老生常谈了
: 有几个注意的点啊
: 1. vectorize your code.
: some designated R functions are much more faster than R for loop even though
: they can achieve the same functionality.
: 2. profile your code.
: by this way you can identity which pieces of your R code take the most
: computational time.
: for those computationally intense code, rewrite it in C. and call it within
: R.

1 (共1页)
进入Statistics版参与讨论
相关主题
弱问一个R的问题
请教一个log scale的运算
大牛指点下面的R Code 怎么用Loop来实现
有个R问题想请交大家
想找人看懂一些R CODE
这个SAS9 ADVANCED 130题烦死我了
请教一道simulation的问题
【分享】SF start-up 电话面试DS 上来就考 coding
R问题请教。
请问R里apply和sapply有什么区别
相关话题的讨论汇总
话题: codes话题: package话题: lot话题: rewrite话题: 运行