我想使用的應用語句做一些數據幀的每一行中R.麻煩適用聲明中的R
下面的作品,我調用函數「calc.Sphere.Metrics」用一堆參數和索引我。我將結果存儲在每一行中。
for(i in 1: dim(position.matrix)[1]){
results.obs[i,] <- calc.Sphere.Metrics(i, culled.mutation.data, position.matrix, protein.metrics, radius)
}
我已經嘗試過幾次應用,但是我沒有運氣。什麼是正確的方法來做到這一點?
編輯: 按照要求,這裏的calc.Sphere.Metrics的骨架
calc.Sphere.Metrics <- function(index, culled.mutation.data, position.matrix, protein.metrics, radius){
results <- matrix(data = 0, nrow = 1, ncol = 8)
colnames(results) <- c("Line.Length","Center", "Start","End","Positions","MutsCount","P.Value", "Within.Range")
results <- as.data.frame(results)
....
look up a bunch of stuff and fill in each column of results. All the data required is in the parameters passed in and the index.
.....
return(results)
}
結果具有相同數量的列在頂部功能results.obs。希望這可以幫助!
謝謝!
我們可能需要以幫助更多的細節。可能是初學者的'calc.Sphere.Metrics'的全部內容。 – joran
calc shere度量標準有點令人困惑,但它所做的是採用索引i,在其他參數(如mutation.data,position.matrix等)中查找特定值,並返回1行8列的數據幀結果(與results.obs完全相同)。 – user1357015
爲什麼只是一個骨架?它真的太長了嗎?我們希望所有的東西都是矢量化的。 – flodel