[R] Sum part of row and add this as a new column vector
Rui Barradas
rui1174 at sapo.pt
Wed Apr 18 00:28:10 CEST 2012
Hello,
Try
df1 <- read.table(text="
County 1990 1991 1992 1993
Alachua 1 1 1 1
Baker 0 0 0 0
Bay 0 0 1 0
Bradford 0 0 0 0
", header=TRUE)
df1$Total <- rowSums(df1[ , -1]) # Not column 1
df1$Total <- rowSums(df1[ , 2:5])# Explicit column numbers
Hope this helps,
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/Sum-part-of-row-and-add-this-as-a-new-column-vector-tp4566097p4566155.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list