2017-12-13 22 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을 당신은'비 기본 유형과 vapply'를 사용할 수 있지만 결과는 목록이 될 것입니다 –

+0

. 당신은 어쨌든리스트로 끝날 것이기 때문에'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