[R] summing columns using partial labels

T Petersen Innkeyp-r at yahoo.com
Tue Apr 5 20:05:36 CEST 2005


I have a dataset of the form

Year  tosk.fai   tosk.isd   tosk.gr  .......  tosk.total       hysa.fai  
hysa.isd ...

and so on. I want to sum all the columns using the first four letters in 
the columns label(e.g. 'tosk', 'hysa' etc.). How can you do that? Also, 
the sums should be without the '.total'column (e.g. 'tosk.total') as 
this serves as a check that everything was done right.

Kind regards




More information about the R-help mailing list