dcast with custom fun.aggregate

做~自己de王妃 提交于 2019-12-06 12:05:49

Disclosure: no R in front of me, but I think your friend here may be the dplyr and tidyr packages.

Certainly lots of ways to accomplish this, but I think the following might get you started

library(dplyr)
library(tidyr)

data %>%
select(gene, sample, ct_lt, length) %>%
group_by(gene, sample) %>%
summarise(weight_avg = sum(ct_lt) / sum(length)) %>%
spread(sample, weight_avg)

Hope this helps...

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