Dear R-list, I have data in the following format: Country 1 Country 2 Country 3 ... 1 0 1 0 2 1 0 2 3 0 1 0 Now I would like to create a variable that counts every non-zero element of the rows, so for the above example it would be: Count 1 1 2 2 3 1 Any help from is greatly appreciated! With kind regards Thomas