How to sum data.frame column values?

后端 未结 4 1594
梦谈多话
梦谈多话 2020-12-07 15:13

I have a data frame with several columns; some numeric and some character. How to compute the sum of a specific column? I’ve googled for this and I see nume

4条回答
  •  悲&欢浪女
    2020-12-07 16:13

    You can just use sum(people$Weight).

    sum sums up a vector, and people$Weight retrieves the weight column from your data frame.

    Note - you can get built-in help by using ?sum, ?colSums, etc. (by the way, colSums will give you the sum for each column).

提交回复
热议问题