我是 R 新手。现在我的功能如下:
funItemAverRating = function()
{
    itemRatingNum = array(0, itemNum);
    print("begin");
    apply(input, 1, function(x)
        {
            itemId = x[2]+1;
            itemAverRating[itemId] <<- itemAverRating[itemId] + x[3];
            itemRatingNum[itemId] <<- itemRatingNum[itemId] + 1;
        }
    );
}
在这个函数中,输入是一个n*3数据框,n是~6*(10e+7),itemRatingNum是一个大小为 的向量~3*(10e+5)。
我的问题是为什么这个apply功能这么慢(需要将近一个小时才能完成)?此外,随着函数的运行,它会使用越来越多的内存。但是正如你所看到的,变量都是在apply函数之外定义的。有谁能够帮我?
程