由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 新手问个R里vectorization的问题
相关主题
support vector machinesas coding help needed
Approximate random sample问个薪水问题并做个调查 (转载)
[合集] 求问我是该继续computational bio还是转biostat?问个r问题
[合集] 这里有没有谁面过Amazon?R Matrix 初级问题
Help: cannot allocate memory block (in R)How to avoid if statement in R
求paper一篇(有包子)两组时间序列的比较
求问一个sas report 里面更换format的问题data clustering by vector correlation distance
置顶的帖子Future for SAS programmers 的一个问题Predict values of vectors generated by black box functions
相关话题的讨论汇总
话题: index话题: vector话题: col话题: 问个
进入Statistics版参与讨论
1 (共1页)
a*******a
发帖数: 1336
1
D是2维矩阵
for (i in 1:n)
{
for (j in 1:n)
{
D[i,j]=f(i, j)
}
}
这样的程序在R里慢得不得了,我用apply(D,1,f())可是不知道f()里怎么写row 和
col index,谢谢各位大侠
l*********s
发帖数: 5409
2
generate a vector of the size n*m, and pass the vector index to your user
defined function f() to construct the data set.
(The rol,col index can be computed from the vector index parameter.)
Then cast the vector into a matrix.
a*******a
发帖数: 1336
3
谢谢,1:n*m的vector算index的话只能用整除/取模么?这样岂不也很慢。。

【在 l*********s 的大作中提到】
: generate a vector of the size n*m, and pass the vector index to your user
: defined function f() to construct the data set.
: (The rol,col index can be computed from the vector index parameter.)
: Then cast the vector into a matrix.

l*********s
发帖数: 5409
4
Integer operation is much faster than float operation.
Computers have no concept about matrix and R has to do the memory I/O behind
scene.Thus you are not going to save computation by writing less codes.

【在 a*******a 的大作中提到】
: 谢谢,1:n*m的vector算index的话只能用整除/取模么?这样岂不也很慢。。
s*****n
发帖数: 2174
5
outer(1:n, 1:n, f)
1 (共1页)
进入Statistics版参与讨论
相关主题
Predict values of vectors generated by black box functionsHelp: cannot allocate memory block (in R)
如何把一个correlation matrix 按照一个table 输入一个 databas (转载)求paper一篇(有包子)
问个matrix的操作问题求问一个sas report 里面更换format的问题
对统计初学者说几句置顶的帖子Future for SAS programmers 的一个问题
support vector machinesas coding help needed
Approximate random sample问个薪水问题并做个调查 (转载)
[合集] 求问我是该继续computational bio还是转biostat?问个r问题
[合集] 这里有没有谁面过Amazon?R Matrix 初级问题
相关话题的讨论汇总
话题: index话题: vector话题: col话题: 问个