vapply fun.value S4
vapply fun.value S4
我很难找到我的 FUN.VALUE 我的 vapply:
> 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 吗?
谢谢
这对我有用:
unlist(vapply(ind, function(x) list(dataset[[x]]), c(new("PlotSetPair")))
诀窍是使用 c()
使其成为一个列表,从而将 dataset[[x]]
强制转换为 list(dataset[[x]]
。那我取消它。
非常感谢@johnColeman @JDL
我很难找到我的 FUN.VALUE 我的 vapply:
> 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 吗?
谢谢
这对我有用:
unlist(vapply(ind, function(x) list(dataset[[x]]), c(new("PlotSetPair")))
诀窍是使用 c()
使其成为一个列表,从而将 dataset[[x]]
强制转换为 list(dataset[[x]]
。那我取消它。
非常感谢@johnColeman @JDL