2017-01-11 26 views
-1

我有一个定义的参考类的列表:使用do.call来获取信息了RC/S4列表的对象

RCclass<-setRefClass("RCclass",field=list(info="character")) 
A<-RCclass$new(info="a") 
B<-RCclass$new(info="b") 
testList<-list(A,B) 

do.call(function(x){paste0(x$info)},testList) 

的do.call功能看起来不正确的,它不会给我期望的字符串“ab”。但我不知道如何实现这一点。请分享你的意见;谢谢!

回答

0

我发现周围一个解决方案:

Reduce("paste0",(lapply(testList,FUN=function(x)x$info)))