Add row to data frame with dplyr

后端 未结 5 1284
隐瞒了意图╮
隐瞒了意图╮ 2021-02-03 23:15

I have this sample data:

cvar <- c(\"2015-11-01\",\"2015-11-02\",\"All\")
nvar1 <- c(12,10,5)
nvar2 <- c(7,5,6)
data <- cbind.data.frame(cvar,nvar1,n         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-03 23:50

    With tibble version 1.2 you can use add_row()

    https://blog.rstudio.org/2016/08/29/tibble-1-2-0/

    data %>% 
     add_row(cvar = "add", nvar1 = sum(nvar1), nvar2 = sum(nvar2))
    

提交回复
热议问题