5

I want to calculate the sum of the columns, but exclude one column.How can I specify what column to exclude while adding the sum of each row.

hd_total<-rowSums(hd) #hd is where the data is that is read is being held 
hn_total<-rowSums(hn)
4

1 回答 1

16
rowSums(hd[, -n])

where n is the column you want to exclude.

于 2013-10-10T14:52:32.440 回答