1
我試圖將以下行(r1)分割爲3段長的段,然後將行1和行2平均分配。我嘗試使用dplyr包,僅僅是因爲我正在嘗試學習它。有人能指引我朝着正確的方向嗎?如何使用dplyr在數據行之間分割數據幀和平均值?
r1<-rbind(c(1,2,3,4,5,6,7,8,9),c(11,21,31,41,51,61,71,81,91))
colnames(r1)<-c("a","b","c","d","e","f","g","h","i")
library(dplyr)
test<-r1 %>% group_by("a","b","c")
目標:
avg(1+11),avg(2+21),avg(3+31)
avg(4+41),avg(5+51),avg(6+61)
avg(7+71),avg(8+81),avg(9+91)
是的,這正是我所期待的,謝謝! – Rilcon42