我已經使用S4類編寫了一個包,並且希望使用函數rbind,cbind和這些定義的類。在包中使用cbind,rbind和s4類的正確方法
因爲它似乎沒有可以定義rbind
和cbind
直接作爲S4的方法我定義rbind2
和cbind2
代替:
setMethod("rbind2", signature(x="ClassA", y = "ANY"),
function(x, y) {
# Do stuff ...
})
setMethod("cbind2", signature(x="ClassA", y = "ANY"),
function(x, y) {
# Do stuff ...
})
從?cbind2
我瞭解到,這些功能都需要使用methods:::bind_activation
,以取代被激活從基地開始綁定和綁定。
我包括使用.onLoad
功能包中的文件R/zzz.R電話:
.onLoad <- function(...) {
# Bind activation of cbind(2) and rbind(2) for S4 classes
methods:::bind_activation(TRUE)
}
可正常工作。然而,運行v CMD檢查,因爲我使用的方法的未導出的功能,我現在得到以下注意事項:
* checking dependencies in R code ... NOTE
Unexported object imported by a ':::' call: 'methods:::bind_activation'
See the note in ?`:::` about the use of this operator.
我怎樣才能擺脫注意的,什麼是定義方法cbind的正確方法和在一個軟件包中安裝S4課程?
你想介紹一下你試圖添加'rbind'和'cbind'方法的幾個S4類的類定義(例如'setClass(「ClassA」,...)')嗎?這將使您更容易爲您的問題找出解決方案。 – nrussell
在這種情況下,類定義應該不重要,因爲它只是方法選擇/調度的問題。所以你可以使用任何定義像setClass(「ClassA」,表示(a =「數字」))。 – user625626
另外,你能否解釋爲什麼「* ...它似乎不可能直接定義rbind和cbind作爲S4方法...... *」 - 也許你試圖實現這個代碼? – nrussell