How can I rename the output rows/cols of **ply functions from plyr?

笑着哭i 提交于 2019-12-04 07:06:19

You have to give names somewhere, either on the function being called inside as eg in

R> ldply(foo, function(l) c(a=signif(l[1], 2), b=signif(l[2], 2), 
+                           c=signif(l[3], 2)))
    .id    a    b    c
1 var.a 0.50 0.72 0.27
2 var.b 0.82 0.38 0.24
3 var.c 0.13 0.27 0.81
R> 

or has you did after the call.

Another option I frequently use is to explicitly create one-row data.frame in the anonymous worker function. *dply() et al then simply collated these into a single data.frame. That works well enough for my tastes.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!