2017-12-13 14 views
1

私は私のvapplyの私のFUN.VALUEどうあるべきかを見つけるのに苦労しています:vapply fun.value S4

> sapply(ind, function(x) typeof(dataset[[x]])) 
[1] "S4" 
> sapply(ind, function(x) mode(dataset[[x]])) 
[1] "S4" 
> sapply(ind, function(x) storage.mode(dataset[[x]])) 
[1] "S4" 
> sapply(ind, function(x) is(dataset[[x]])) 
[,1]   
[1,] "PlotSetPair" 
[2,] "envRefClass" 
[3,] ".environment" 
[4,] "refClass"  
[5,] "environment" 
[6,] "refObject" 
[7,] "AssayData" 

私は成功せず、次の可能性を試してみました:

> vapply(ind, function(x){return(dataset[[x]]);}, S4) 
Error in vapply(ind, function(x) { : object 'S4' not found 
> vapply(ind, function(x){return(dataset[[x]]);}, "S4") 
Error in vapply(ind, function(x) { : values must be type 'character', 
but FUN(X[[1]]) result is type 'S4' 
> vapply(ind, function(x){return(dataset[[x]]);}, "S4-class") 
Error in vapply(ind, function(x) { : values must be type 'character', 
but FUN(X[[1]]) result is type 'S4' 
> vapply(ind, function(x){return(dataset[[x]]);}, S4-class) 
Error in vapply(ind, function(x) { : object 'S4' not found 
> vapply(ind, function(x){return(dataset[[x]]);}, PlotSetPair) 
Error in vapply(ind, function(x) { : object 'PlotSetPair' not found 
> vapply(ind, function(x){return(dataset[[x]]);}, PlotSetPair()) 
Error in PlotSetPair() : could not find function "PlotSetPair" 
> vapply(ind, function(x){return(dataset[[x]]);}, seqplots::PlotSetPair()) 
Error: 'PlotSetPair' is not an exported object from 'namespace:seqplots' 
> vapply(ind, function(x){return(dataset[[x]]);}, seqplots::PlotSetPair) 
Error: 'PlotSetPair' is not an exported object from 'namespace:seqplots' 
> vapply(ind, function(x){return(dataset[[x]]);}, PlotSetPair-class) 
Error in vapply(ind, function(x) { : object 'PlotSetPair' not found 

です解決策がありますか?プリミティブ型でvapplyだけを使用できますか?

おかげ

+0

おそらく関連:https://stackoverflow.com/q/16366739/4996248 –

+0

あなたが非プリミティブ型で 'vapply'を使用することができますが、結果はリストになります。あなたは代わりに 'lapply'を使用するかもしれません。なぜなら、あなたはリストで終わるからです。 – JDL

+0

これは私にとってはうまくいった: 'unlist(vapply(ind、function(x)list(dataset [[x]])、c(new(" PlotSetPair ")))'おかげでたくさん@johnColeman @JDL – nicoluca

答えて

1

これは私の仕事は:

unlist(vapply(ind, function(x) list(dataset[[x]]), c(new("PlotSetPair")))

トリックはそれをリストを作成するc()を使用しているためlist(dataset[[x]]dataset[[x]]を強制することでした。私はそれからリストを外します。

どうもありがとう@johnColeman @JDL

関連する問題