Avoid two for loops in R

前端 未结 6 760
执念已碎
执念已碎 2021-02-08 11:15

I have a R code that can do convolution of two functions...

convolveSlow <- function(x, y) {  
nx <- length(x); ny <- length(y)  
xy <- numeric(nx          


        
6条回答
  •  太阳男子
    2021-02-08 11:45

    Some say the apply() and sapply() functions are faster than for() loops in R. You could convert the convolution to a function and call it from within apply(). However, there is evidence to the contrary http://yusung.blogspot.com/2008/04/speed-issue-in-r-computing-apply-vs.html

提交回复
热议问题