How do I make a column that sums only numeric columns?

前端 未结 2 736
一生所求
一生所求 2021-01-27 10:41

I have a dataframe with a lot of columns.

LABEL    COL1  COL2  COL3
Meat     10    20    30
Veggies  20    30    40

How do I make column named

2条回答
  •  孤城傲影
    2021-01-27 11:36

    I ended up using this code:

    df$SUMCOL <- rowSums(df[sapply(df, is.numeric)], na.rm = TRUE)

提交回复
热议问题