我在R中的以下數據框: ID year event_year
432674326 2000 NA
432674326 2001 NA
432674326 2002 NA
432674326 2003 NA
432674326 2004 NA
432674326 2005 2005_1
432674326 2006 NA
432674326 2007 NA
432674326
我試圖做一些事情我已經有ddply在dplyr 這是什麼在起作用: library(plyr)
library(dplyr)
library(matrixStats)
mtcars2 = tbl_df(mtcars) %>%
mutate(car = rownames(mtcars))
# compute the weighted mean (I use cyl just