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 numerous functions (sum
, cumsum
, rowsum
, rowSums
, colSums
, aggregate
, apply
) but I can’t make sense of it all.
For example suppose I have a data frame people
with the following columns
people <- read.table(
text =
"Name Height Weight
Mary 65 110
John 70 200
Jane 64 115",
header = TRUE
)
…
How do I get the sum of all the weights?
[1] NA
. I looked at the data for this column and the very last row has NA, is that why? – Overindulge