final.marks
# raj sanga rohan rahul
#physics 45 43 44 49
#chemistry 47 45 48 47
#total 92 88 92 96
This is the matrix I have. Now I want to find the total for each subject separately across respective subject rows and add them as a new column to the above matrix as the 5th column . However my code i.e class.marks.chemistry<- rowSums(final.marks[2,])
keeps producing an error saying
Error saying rowSums(final.marks[2, ]) : 'x' must be an array of at least two dimensions
Can you please help me solve it. I am very new to R or any form of scripting or programming background.