Rui Barradas
2012-Apr-17 22:28 UTC
[R] Sum part of row and add this as a new column vector
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.