我试图创建一个as.data.frame.by
方法,该方法基本上融合了N维的对象以便与latex.table.by
一起使用。通过解析其调用获取来自对象的索引名称
融化它非常简单,因为by对象只是一个矩阵,但是返回的变量名是最不具有描述性的“X”的想象。
dat <- transform(ChickWeight, Time=cut(Time,3), Chick=cut(as.numeric(Chick),3))
my.by <- by(dat, with(dat,list(Time,Chick,Diet)), function(x) sum(x$weight))
翻翻attributes(my.by)
任何地方都不会透露的变量名都存储除了呼叫的指数。我想默认为表格合理描述。
使叶片解析电话:
> attr(my.by,"call")
by.data.frame(data = dat, INDICES = with(dat, list(Time, Chick,
Diet)), FUN = function(x) sum(x$weight))
> str(attr(my.by,"call"))
language by.data.frame(data = dat, INDICES = with(dat, list(Time, Chick, Diet)), FUN = function(x) sum(x$weight))
我只是想使用的索引的名字,但我不知道如何去分析这个怪物。想法?
不错。回想起来似乎很简单。谢谢! –