sum two columns in R

前端 未结 6 1668
情书的邮戳
情书的邮戳 2020-12-03 14:00

I feel a bit embarrassed as I am trying to add two columns in R to get the product.

I have tried

sum(col1,col2)

but this returns

6条回答
  •  青春惊慌失措
    2020-12-03 14:45

    Try this for creating a column3 as a sum of column1 + column 2 in a table

    tablename$column3=rowSums(cbind(tablename$column1,tablename$column2))
    

提交回复
热议问题