I'm a student and working on a project and I fail to do a basic thing in R and its very frustrating.
data <- read.xlsx("dataset.xlsx",1, header=1)
#Creating a matrix with headers.
matrix <- as.matrix(data, row.names=1, col.names=1)
Sum <- rowSums(matrix, na.rm = FALSE, dims = 1)
The data looks something like this:
    Point1  Point2   Point3
SP1  0      1        1
SP1  0      1        0
SP1  1      1        0
SP1  1      1        1
SP1  0      1        0
This data is located and imported in R using the xlsx package. After that I want to calculate the row sums and import it in the matrix to create something like this:
    Point1  Point2   Point3  Sums
SP1  0      1        1       2
SP1  0      1        0       1
SP1  1      1        0       2
SP1  1      1        1       3
SP1  0      1        0       1
However, I can't get this to work. The code I used keeps returning non-numeric value. Obviously it probably tries to calculate with the first row and column, which are headers. For future purposes, Id like R to exclude the first row and column always and treat them as headers and treat the 0 and 1s as numeric.
Could you guys help me out here?
Cheers Jasper
 
    