我很难找到我的vapply的FUN.VALUE应该是什么:
> 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与原始类型一起使用?
谢谢
发布于 2017-12-15 02:41:10
这对我很有效:
unlist(vapply(ind, function(x) list(dataset[[x]]), c(new("PlotSetPair")))
诀窍是使用c()使其成为列表,从而将dataset[[x]]强制为list(dataset[[x]]。那我就把它去掉吧。
非常感谢@johnColeman @JDL
https://stackoverflow.com/questions/47793227
复制相似问题