Why R is giving me different sums and counts of rows than Excel?

I've discovered an issue when calculating sum of rows and counts (">0") in my data frame. I'm trying to sum rows to have abundance and richness of a community data "spe" (51 columns(taxa) and 82 rows(sites)). I realize this when double checking the sums and counts in R and Excel. Why is this happening? This is the code I use in R:
For Sum:
apply(spe[,-1],1,sum)
For Counts:
apply(spe[,-1]>0,1,sum)

I've noticed the first rows goes well with the sums and counts, but then the results in R are different by subtracting numbers in sums and just 1 less in the counts issue, and after some rows, there are some good with the sums and counts but not all of them comparing to Excel. Why is that happening? Can someone help me please? Thanks in advance.

spe<-data.frame(read.table("~/Dropbox/Docs Redro/Paper Tesis MBC/MBC_SPP_ALL.csv", sep=",", header=TRUE, row.names=1))
head(spe)
#>   Duge Allua1 Ande Anom Atop1 Atop2 Bleph1 Bleph2 Bleph3 Caillo2 Caillo3
#> 2    0      0    0    0     1     0      0      0      0       0       0
#> 3    0      0    0    0     0     0      0      0      0       0       0
#> 4    0      0    0    0     0     0      0      0      0       0       0
#> 5    0      0    0    0     0     0      0      0      0       0       0
#> 8    0      0    0    0     0     0      0      0      0       0       0
#> 9    0      0    0    0     0     0      0      0      0       0       0
#>   Caillo1 Ceratoindet Cheli2 chiroindet Chiroinae Claudio Contu Corix2 Crambi
#> 2       2           0      1          0         0       0     0      0      0
#> 3       0           0      0          0         0       0     0      0      0
#> 4       3           0      2          0         0       0     0      0      0
#> 5       0           0      0          0         0       0     0      0      0
#> 8       6           0      0          0         0       0     0      0      0
#> 9       0           0      0          0         0       0     0      0      0
#>   Curcu1 Curcu2 Diame1 Diame2 Dimec Dytis1 Ephyd2 Geran Helicho Hemer1 Hyale
#> 2      0      0      1      0     0      0      0     0       0      2     0
#> 3      0      0      0      0     0      0      0     0       0      0     0
#> 4      0      0      2      1     0      0      0     0       0      1     0
#> 5      0      0      0      0     0      0      0     0       0      0     0
#> 8      0      0      0      0     0      1      0     0       0      0     0
#> 9      0      0      1      0     0      0      0     0       0      0     0
#>   HYDRA Hydrosc Leech1 Leech2 Leech3 Leech4 Leuco Limoniindet Lumbri Lymnae
#> 2     0       0      0      0      0      0     0           0      0      0
#> 3     0       0      0      0      0      0     0           0      0      0
#> 4     0       0      0      0      2      0     0           0      0      0
#> 5     0       0      0      0      0      0     0           0      0      0
#> 8     0       0      0      0      0      0     0           0      0      0
#> 9     0       0      0      0      0      0     0           0      0      0
#>   Maya Molo1 Molo2 Morto Musci5 Musci6 Musci7 Musci4 Musci1 Musci2 Musci3 Naid1
#> 2    0     1     0     0      0      0      0      1     11      0      0    39
#> 3    0     0     0     0      0      0      0      0      0      0      0     0
#> 4    0     0     0     0      0      0      0      0      8      0      0    32
#> 5    0     0     0     0      0      0      0      1      0      0      0     0
#> 8    0     0     1     0      0      0      0      0      2      0      0     0
#> 9    0     0     0     0      0      0      0      0      0      0      0     0
#>   Naid2 Naid3 Nectop Nema Neoel1 Neoel2 Neot Nepti Nona1 Ochro Ortho Ostra
#> 2     0     0      0    2      0      0    0     0     0     0    72     0
#> 3     0     0      0    0      0      0    0     0     0     0     0     0
#> 4     0     0      0    4      0      1    0     0     0     0    85     0
#> 5     0     0      0    0      0      0    0     0     0     0     7     0
#> 8     0     0      0    2      0      0    0     0     0     0    43     0
#> 9     0     0      0    0      0      0    0     0     0     0     2     0
#>   Podo1 Podo2 Podo3 Podo4 Priono1 Priono2 Priono3 Schoe Simu1 Sphae Staphy1
#> 2    24     0     4     1       0       0       0     0   124     0       1
#> 3    16     0    28     0       0       0       0     0     0     0       0
#> 4   177     0     2     2       0       0       0     0    18     0       0
#> 5    13     0    71     1       0       0       0     0     0     0       0
#> 8    46     0     3     0       0       0       0     0     3     0       0
#> 9    49     0    20    14       0       0       0     0     0     0       1
#>   Staphy2 Stilo1 Sync1 Tanyp Tipu Trichoco
#> 2       0      0     0     0    0        0
#> 3       0      0     0     0    0        0
#> 4       0      0     0     0    0        0
#> 5       0      0     0     0    0        0
#> 8       0      0     0     0    0        0
#> 9       0      0     0     0    0        0

# Spp Richness
apply(spe[,-1]>0,1,sum)
#>  2  3  4  5  8  9  1  7 37 38 47 24 46 43 45 50 40 42 14 49 51 29 30 31 33  6 
#> 16  2 15  5  9  6 17 17 10 15 19 33 27 34 31 27 20 25 32 29 30 26 35 34 25 20 
#> 41 26 27 34 35 10 15 16 17 18 19 20 21 22 25 28 32 36 48 13 12 11 23 39 44 
#> 24 22 24 29 26 18 25 26 24 33 26 24 16 27 21 36 14 31 25 33 15 27 30 17 21

# Abundance
apply(spe[,-1],1,sum)
#>    2    3    4    5    8    9    1    7   37   38   47   24   46   43   45   50 
#>  287   44  340   93  107   87  214  268  112   58  788 1554 1225 2683  990 2757 
#>   40   42   14   49   51   29   30   31   33    6   41   26   27   34   35   10 
#>  213  348 1508 1479 1459 1026 2961 2807 2586  760  629 2074 1254 2104 9976  531 
#>   15   16   17   18   19   20   21   22   25   28   32   36   48   13   12   11 
#> 1645 4161 1371 4132 1407 3807 4047 1619 4314 3057  232 3348 1457 1633 2240 2084 
#>   23   39   44 
#> 1734  553 2774

dput(head(spe))
#> structure(list(Duge = c(0L, 0L, 0L, 0L, 0L, 0L), Allua1 = c(0L, 
#> 0L, 0L, 0L, 0L, 0L), Ande = c(0L, 0L, 0L, 0L, 0L, 0L), Anom = c(0L, 
#> 0L, 0L, 0L, 0L, 0L), Atop1 = c(1L, 0L, 0L, 0L, 0L, 0L), Atop2 = c(0L, 
#> 0L, 0L, 0L, 0L, 0L), Bleph1 = c(0L, 0L, 0L, 0L, 0L, 0L), Bleph2 = c(0L, 
#> 0L, 0L, 0L, 0L, 0L), Bleph3 = c(0L, 0L, 0L, 0L, 0L, 0L), Caillo2 = c(0L, 
#> 0L, 0L, 0L, 0L, 0L), Caillo3 = c(0L, 0L, 0L, 0L, 0L, 0L), Caillo1 = c(2L, 
#> 0L, 3L, 0L, 6L, 0L), Ceratoindet = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Cheli2 = c(1L, 0L, 2L, 0L, 0L, 0L), chiroindet = c(0L, 0L, 
#>     0L, 0L, 0L, 0L), Chiroinae = c(0L, 0L, 0L, 0L, 0L, 0L), Claudio = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Contu = c(0L, 0L, 0L, 0L, 0L, 0L), Corix2 = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Crambi = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Curcu1 = c(0L, 0L, 0L, 0L, 0L, 0L), Curcu2 = c(0L, 0L, 0L, 
#>     0L, 0L, 0L), Diame1 = c(1L, 0L, 2L, 0L, 0L, 1L), Diame2 = c(0L, 
#>     0L, 1L, 0L, 0L, 0L), Dimec = c(0L, 0L, 0L, 0L, 0L, 0L), Dytis1 = c(0L, 
#>     0L, 0L, 0L, 1L, 0L), Ephyd2 = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Geran = c(0L, 0L, 0L, 0L, 0L, 0L), Helicho = c(0L, 0L, 0L, 
#>     0L, 0L, 0L), Hemer1 = c(2L, 0L, 1L, 0L, 0L, 0L), Hyale = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), HYDRA = c(0L, 0L, 0L, 0L, 0L, 0L), Hydrosc = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Leech1 = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Leech2 = c(0L, 0L, 0L, 0L, 0L, 0L), Leech3 = c(0L, 0L, 2L, 
#>     0L, 0L, 0L), Leech4 = c(0L, 0L, 0L, 0L, 0L, 0L), Leuco = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Limoniindet = c(0L, 0L, 0L, 0L, 0L, 
#>     0L), Lumbri = c(0L, 0L, 0L, 0L, 0L, 0L), Lymnae = c(0L, 0L, 
#>     0L, 0L, 0L, 0L), Maya = c(0L, 0L, 0L, 0L, 0L, 0L), Molo1 = c(1L, 
#>     0L, 0L, 0L, 0L, 0L), Molo2 = c(0L, 0L, 0L, 0L, 1L, 0L), Morto = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Musci5 = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Musci6 = c(0L, 0L, 0L, 0L, 0L, 0L), Musci7 = c(0L, 0L, 0L, 
#>     0L, 0L, 0L), Musci4 = c(1L, 0L, 0L, 1L, 0L, 0L), Musci1 = c(11L, 
#>     0L, 8L, 0L, 2L, 0L), Musci2 = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Musci3 = c(0L, 0L, 0L, 0L, 0L, 0L), Naid1 = c(39L, 0L, 32L, 
#>     0L, 0L, 0L), Naid2 = c(0L, 0L, 0L, 0L, 0L, 0L), Naid3 = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Nectop = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Nema = c(2L, 0L, 4L, 0L, 2L, 0L), Neoel1 = c(0L, 0L, 0L, 
#>     0L, 0L, 0L), Neoel2 = c(0L, 0L, 1L, 0L, 0L, 0L), Neot = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Nepti = c(0L, 0L, 0L, 0L, 0L, 0L), Nona1 = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Ochro = c(0L, 0L, 0L, 0L, 0L, 0L), Ortho = c(72L, 
#>     0L, 85L, 7L, 43L, 2L), Ostra = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Podo1 = c(24L, 16L, 177L, 13L, 46L, 49L), Podo2 = c(0L, 0L, 
#>     0L, 0L, 0L, 0L), Podo3 = c(4L, 28L, 2L, 71L, 3L, 20L), Podo4 = c(1L, 
#>     0L, 2L, 1L, 0L, 14L), Priono1 = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Priono2 = c(0L, 0L, 0L, 0L, 0L, 0L), Priono3 = c(0L, 0L, 
#>     0L, 0L, 0L, 0L), Schoe = c(0L, 0L, 0L, 0L, 0L, 0L), Simu1 = c(124L, 
#>     0L, 18L, 0L, 3L, 0L), Sphae = c(0L, 0L, 0L, 0L, 0L, 0L), 
#>     Staphy1 = c(1L, 0L, 0L, 0L, 0L, 1L), Staphy2 = c(0L, 0L, 
#>     0L, 0L, 0L, 0L), Stilo1 = c(0L, 0L, 0L, 0L, 0L, 0L), Sync1 = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Tanyp = c(0L, 0L, 0L, 0L, 0L, 0L), Tipu = c(0L, 
#>     0L, 0L, 0L, 0L, 0L), Trichoco = c(0L, 0L, 0L, 0L, 0L, 0L)), row.names = c(2L, 
#> 3L, 4L, 5L, 8L, 9L), class = "data.frame")

Created on 2020-03-24 by the reprex package (v0.3.0)

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

Now I've added a minimal dataset using reprex, thanks a lot.

I think @andresrcs is looking for an actual data set. We do not have access to your file and, therefore, cannot run your code. The reproducible example should, ideally, be completely self-contained.

I can't reproduce your issue, I get exactly the same results on R and Excel with your sample data.

spe <- structure(list(Duge = c(0L, 0L, 0L, 0L, 0L, 0L), Allua1 = c(0L, 
 0L, 0L, 0L, 0L, 0L), Ande = c(0L, 0L, 0L, 0L, 0L, 0L), Anom = c(0L, 
 0L, 0L, 0L, 0L, 0L), Atop1 = c(1L, 0L, 0L, 0L, 0L, 0L), Atop2 = c(0L, 
 0L, 0L, 0L, 0L, 0L), Bleph1 = c(0L, 0L, 0L, 0L, 0L, 0L), Bleph2 = c(0L, 
 0L, 0L, 0L, 0L, 0L), Bleph3 = c(0L, 0L, 0L, 0L, 0L, 0L), Caillo2 = c(0L, 
 0L, 0L, 0L, 0L, 0L), Caillo3 = c(0L, 0L, 0L, 0L, 0L, 0L), Caillo1 = c(2L, 
 0L, 3L, 0L, 6L, 0L), Ceratoindet = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Cheli2 = c(1L, 0L, 2L, 0L, 0L, 0L), chiroindet = c(0L, 0L, 
     0L, 0L, 0L, 0L), Chiroinae = c(0L, 0L, 0L, 0L, 0L, 0L), Claudio = c(0L, 
     0L, 0L, 0L, 0L, 0L), Contu = c(0L, 0L, 0L, 0L, 0L, 0L), Corix2 = c(0L, 
     0L, 0L, 0L, 0L, 0L), Crambi = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Curcu1 = c(0L, 0L, 0L, 0L, 0L, 0L), Curcu2 = c(0L, 0L, 0L, 
     0L, 0L, 0L), Diame1 = c(1L, 0L, 2L, 0L, 0L, 1L), Diame2 = c(0L, 
     0L, 1L, 0L, 0L, 0L), Dimec = c(0L, 0L, 0L, 0L, 0L, 0L), Dytis1 = c(0L, 
     0L, 0L, 0L, 1L, 0L), Ephyd2 = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Geran = c(0L, 0L, 0L, 0L, 0L, 0L), Helicho = c(0L, 0L, 0L, 
     0L, 0L, 0L), Hemer1 = c(2L, 0L, 1L, 0L, 0L, 0L), Hyale = c(0L, 
     0L, 0L, 0L, 0L, 0L), HYDRA = c(0L, 0L, 0L, 0L, 0L, 0L), Hydrosc = c(0L, 
     0L, 0L, 0L, 0L, 0L), Leech1 = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Leech2 = c(0L, 0L, 0L, 0L, 0L, 0L), Leech3 = c(0L, 0L, 2L, 
     0L, 0L, 0L), Leech4 = c(0L, 0L, 0L, 0L, 0L, 0L), Leuco = c(0L, 
     0L, 0L, 0L, 0L, 0L), Limoniindet = c(0L, 0L, 0L, 0L, 0L, 
     0L), Lumbri = c(0L, 0L, 0L, 0L, 0L, 0L), Lymnae = c(0L, 0L, 
     0L, 0L, 0L, 0L), Maya = c(0L, 0L, 0L, 0L, 0L, 0L), Molo1 = c(1L, 
     0L, 0L, 0L, 0L, 0L), Molo2 = c(0L, 0L, 0L, 0L, 1L, 0L), Morto = c(0L, 
     0L, 0L, 0L, 0L, 0L), Musci5 = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Musci6 = c(0L, 0L, 0L, 0L, 0L, 0L), Musci7 = c(0L, 0L, 0L, 
     0L, 0L, 0L), Musci4 = c(1L, 0L, 0L, 1L, 0L, 0L), Musci1 = c(11L, 
     0L, 8L, 0L, 2L, 0L), Musci2 = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Musci3 = c(0L, 0L, 0L, 0L, 0L, 0L), Naid1 = c(39L, 0L, 32L, 
     0L, 0L, 0L), Naid2 = c(0L, 0L, 0L, 0L, 0L, 0L), Naid3 = c(0L, 
     0L, 0L, 0L, 0L, 0L), Nectop = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Nema = c(2L, 0L, 4L, 0L, 2L, 0L), Neoel1 = c(0L, 0L, 0L, 
     0L, 0L, 0L), Neoel2 = c(0L, 0L, 1L, 0L, 0L, 0L), Neot = c(0L, 
     0L, 0L, 0L, 0L, 0L), Nepti = c(0L, 0L, 0L, 0L, 0L, 0L), Nona1 = c(0L, 
     0L, 0L, 0L, 0L, 0L), Ochro = c(0L, 0L, 0L, 0L, 0L, 0L), Ortho = c(72L, 
     0L, 85L, 7L, 43L, 2L), Ostra = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Podo1 = c(24L, 16L, 177L, 13L, 46L, 49L), Podo2 = c(0L, 0L, 
     0L, 0L, 0L, 0L), Podo3 = c(4L, 28L, 2L, 71L, 3L, 20L), Podo4 = c(1L, 
     0L, 2L, 1L, 0L, 14L), Priono1 = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Priono2 = c(0L, 0L, 0L, 0L, 0L, 0L), Priono3 = c(0L, 0L, 
     0L, 0L, 0L, 0L), Schoe = c(0L, 0L, 0L, 0L, 0L, 0L), Simu1 = c(124L, 
     0L, 18L, 0L, 3L, 0L), Sphae = c(0L, 0L, 0L, 0L, 0L, 0L), 
     Staphy1 = c(1L, 0L, 0L, 0L, 0L, 1L), Staphy2 = c(0L, 0L, 
     0L, 0L, 0L, 0L), Stilo1 = c(0L, 0L, 0L, 0L, 0L, 0L), Sync1 = c(0L, 
     0L, 0L, 0L, 0L, 0L), Tanyp = c(0L, 0L, 0L, 0L, 0L, 0L), Tipu = c(0L, 
     0L, 0L, 0L, 0L, 0L), Trichoco = c(0L, 0L, 0L, 0L, 0L, 0L)), row.names = c(2L, 
 3L, 4L, 5L, 8L, 9L), class = "data.frame")

rowSums(spe[,-1])
#>   2   3   4   5   8   9 
#> 287  44 340  93 107  87

rowSums(spe[,-1] > 0)
#>  2  3  4  5  8  9 
#> 16  2 15  5  9  6

image

Ok, but how do I upload my data file here? I think .xls or .csv is not allowed :frowning:

You can upload the file to a cloud storage service (e.g. Dropbx, Google Drive, Box, etc) and post a link.

Yes, but look at the entire data set, since row 13 there are a mistakes in sums and counts:

Well then, try to share sample data that reproduces your issue, if I can't reproduce, I can't see what is going on and help you.

Good, but how can I share with you my sample data? Here in upload, I cannot upload csv or xls files :frowning:

Here it is with reprex:

spe<-data.frame(read.table("~/Dropbox/Docs Redro/Paper Tesis MBC/MBC_SPP_ALL.csv", sep=",", header=TRUE, row.names=1))
spe
#>    Duge Allua1 Ande Anom Atop1 Atop2 Bleph1 Bleph2 Bleph3 Caillo2 Caillo3
#> 2     0      0    0    0     1     0      0      0      0       0       0
#> 3     0      0    0    0     0     0      0      0      0       0       0
#> 4     0      0    0    0     0     0      0      0      0       0       0
#> 5     0      0    0    0     0     0      0      0      0       0       0
#> 8     0      0    0    0     0     0      0      0      0       0       0
#> 9     0      0    0    0     0     0      0      0      0       0       0
#> 1     0      7   15    0     1     0      0      0      0       0       0
#> 7     0     11   48    0     4     0      1      0      0       0       0
#> 37    0      0   10    0     2     0      0      0      0       0       0
#> 38    0      6   11    0     0     0      0      0      0       0       0
#> 47   21    173  165    0     9     0      0      0      0       0       0
#> 24  100     85  774    0     6     0      0      0      0       0       0
#> 46    8    369  189    0     7     0      0      0      0       0       0
#> 43    3    161 1032   11    12     0      2      0      0       0       0
#> 45    4     26  354    4     0     0      0      0      0       0       0
#> 50   26    245 1146    0     8     0      4      0      2       0       0
#> 40   13      8   40    1     7     0      1      0      0       0       0
#> 42   15      4   51   29     5     0     94      0      0       0       0
#> 14    2      7  175  122     5     0     11      0      0       0       0
#> 49   18      2  686  103     5     0      0      0      0       0       0
#> 51    2     21  223   90     0     0     17      9      3       0       0
#> 29    2      0  165   88     4     0     19      0      0       1       0
#> 30    8      3  470   28     2     0      3      0      0       0       0
#> 31   16      1   34   22     3     0      7      3      0       0       3
#> 33    9      1   51   30     0     0      0      0      0       1       0
#> 6     0     56   72    0     8     0      0      0      0       0       0
#> 41   16      8  139  154     8     0      0      0      0       0       0
#> 26    2     52 1445    2     1     0      0      0      0       0       0
#> 27   31     81  369   62     2     0      0      0      0       0       0
#> 34   22    194  149    1     8     1      4      0      0       0       0
#> 35   74      8  127   23     1     0      0      0      0       0       0
#> 10    3      0  108   26     2     0      0      0      0       0       0
#> 15   49      0   11  438     0     2      0      0      0       0       0
#> 16   41      3  164  183     0     0      0      0      0       0       0
#> 17    8      0   53   62     0     0      0      0      0       0       0
#> 18    3    298   17   11     0     0      0      0      0       3       0
#> 19    0     29  198   35    15     0      0      0      0       0       0
#> 20   48      7  774    0    17     0      0      0      0       0       0
#> 21    2      0    0    4     0     0      0      0      0       0       0
#> 22   45      0  542  174     1     0      0      0      0       0       0
#> 25   81    121   14    0     0     0      0      0      0       0       0
#> 28   34      7  597    0     3     0     62      3      0       0       0
#> 32    0      0    2    0     0     0      0      0      0       0       0
#> 36   19    124  113   82    15     0      0      0      0       0       0
#> 48    1      5   28    0    36     0      0      0      0       0       0
#> 13   99      3  173  226     1     0      0      0      0       0       0
#> 12  160      0 1085  365    20     0      0      0      0       0       0
#> 11   32      0    9    3     0     0      0      0      0       0       0
#> 23   99      0  252    5     1     0      0      0      0       1       0
#> 39    2      0   99    0     3     0      0      0      0       0       0
#> 44   23      0  518  191     0     0      0      0      0       0       0
#>    Caillo1 Ceratoindet Cheli2 chiroindet Chiroinae Claudio Contu Corix2 Crambi
#> 2        2           0      1          0         0       0     0      0      0
#> 3        0           0      0          0         0       0     0      0      0
#> 4        3           0      2          0         0       0     0      0      0
#> 5        0           0      0          0         0       0     0      0      0
#> 8        6           0      0          0         0       0     0      0      0
#> 9        0           0      0          0         0       0     0      0      0
#> 1        3           0      3          0         1       0     0      0      0
#> 7        8           0      9          0         0       0     0      0      0
#> 37       0           0      0          0         0       1     0      0      0
#> 38       1           0      0          0         0       0     0      0      0
#> 47       3           0      3          0         3       3     0      0      0
#> 24       7           0      0          9         4       6     0      0      0
#> 46       3           1     14          2         9      16     0      0      0
#> 43      44           0     32          0        13      25     0      0      0
#> 45       1           0      4          0         2       4     0      0      0
#> 50       0           0      1          0         3      59     0      0      0
#> 40       0           0      0          0         1       0     0      0      0
#> 42       3           0      0          0         5       1     0      0      0
#> 14      15           0     34          0        20       1     0      0      0
#> 49      14           0     31          2        19       4     0      0      0
#> 51       4           0     19          0         2       0     0      0      0
#> 29       4           0     27          0         2       0     0      0      0
#> 30       9           0     23          0       144       3     0      0      0
#> 31       8           0     26          0        27       2     4      0      0
#> 33       0           0      6          0         3       0     0      0      0
#> 6        1           0      2          0         4       2     0      0      0
#> 41       1           0      3          0        12       0     0      0      0
#> 26       2           0      0          0         0       1     0      0      0
#> 27       3           0      2          0         1       0     0      0      0
#> 34       3           1      9          0         0       1     0      0      0
#> 35      13           0     18          0         5       0     0      0      0
#> 10       0           0      9          0        16       0     0      0      0
#> 15       0           0      9          0         2       0     0      0      0
#> 16       0           0     17          0        19       4     0      0      0
#> 17       0           0      5          0        17       2     0      0      0
#> 18       9          11    117          1        62       9    15      0      0
#> 19       1           0     19          0         4       0     0      0      0
#> 20       0           0      0          1       182       0     0      0      0
#> 21       0           0      2          0         0       0     0      0      0
#> 22      10           0      3          0        49       0     0      0      0
#> 25       0           1      0          0         1       0     0      4      0
#> 28      12           0    175         19         7      55   263      0      0
#> 32       0           0      1          0         0       0     0      0      1
#> 36      21           2     39          0        24       7    16      0      0
#> 48       7           0      0          5        33       0     0      0      0
#> 13       1           0      5          0         3       1     0      0      0
#> 12       2           0     24          0         6       3     0      0      0
#> 11       0           0      0          0         0       0     0      0      0
#> 23      25           0      2          0         2       7     1      0      1
#> 39       0           0      0          0         0       0     0      0      0
#> 44       0           0      3          0        19       0     0      0      0
#>    Curcu1 Curcu2 Diame1 Diame2 Dimec Dytis1 Ephyd2 Geran Helicho Hemer1 Hyale
#> 2       0      0      1      0     0      0      0     0       0      2     0
#> 3       0      0      0      0     0      0      0     0       0      0     0
#> 4       0      0      2      1     0      0      0     0       0      1     0
#> 5       0      0      0      0     0      0      0     0       0      0     0
#> 8       0      0      0      0     0      1      0     0       0      0     0
#> 9       0      0      1      0     0      0      0     0       0      0     0
#> 1       0      0      0      0     0      0      0     0       0      0     0
#> 7       0      0      0      0     0      0      0     0       0      1     0
#> 37      0      0      0      0     0      0      0     0       0      0     1
#> 38      1      0      2      0     0      0      0     0       0      0     0
#> 47      0      0      0      0     0      0      0     0       0      0     2
#> 24      0      0      1      1     2      0      0     0       0      0    39
#> 46      0      0      0      0     0      0      0     0       0      0     9
#> 43      0      0     16      8     1      0      0     0       0      0    14
#> 45      0      0      3      4     0      0      0     1       0      0    65
#> 50      0      0      0      0     0      0      0     0       0      0    11
#> 40      0      0      0      0     0      0      0     0       0      0   103
#> 42      1      0      3      5     0      0      0     0       0      0    18
#> 14      0      0     24     10     0      0      0     0       0      1    36
#> 49      0      0     28      6     0      0      0     0       0      0    32
#> 51      0      0      0      2     0      0      0     0       0      0    45
#> 29      0      0     21      6     0      0      0     0       0      0     9
#> 30      0      0     59     16     0      0      0     0       0      4   166
#> 31      0      0    131     43     0      0      0     0       0      0    32
#> 33      0      0     56     20     0      0      0     0       0      1     9
#> 6       0      0      0      0     0      0      0     0       0      0     0
#> 41      0      0      1      5     0      0      0     0       0      0    32
#> 26      0      0      0      0     0      0      0     0       0      0    41
#> 27      0      0      6      2     0      0      0     2       0      0   245
#> 34      0      0      2      2     0      0      0     0       0      0    18
#> 35      0      0    239    143     0      0      0     0       1      0     3
#> 10      0      0      0      0     0      0      0     0       1      0    20
#> 15      0      0     28      9     0      0      0     0       0      4   219
#> 16      0      0     33     11     0      0      0     0      11      1  1867
#> 17      0      0      1      0     0      0      0     0       0      0   418
#> 18      1      0    168     41     0      0      0     0       0      0    19
#> 19      0      0      1      0     1      0      0     0       0      0    23
#> 20      0      0      0      1     0      0      0     1       0      0  1871
#> 21      0      0      1      0     0      0      0     0       0      0  3230
#> 22      0      0      7      1     1      0      0     0       0      0   389
#> 25      0      0      0      0     0      0      0     1       0      0  1548
#> 28      0      0     14    133     0      0      0     2       5      0    73
#> 32      0      0      1      0     0      0      0     0       0      0     5
#> 36      1      0     61     18     0      0      0     0       0      0    12
#> 48      0      1      0      0     0      0      0     3       0      5   474
#> 13      0      0      1      1     0      0      0     1       0      0   350
#> 12      0      0      0      0     0      0      0     0       0      0   149
#> 11      0      0      0      3     3      0      1     0       0      4   906
#> 23      0      0      3      0     0      0      0     0       0      0   648
#> 39      0      0      0      0     0      0      0     0       0      0   290
#> 44      0      0      0      0     0      0      0     0       0      0  1621
#>    HYDRA Hydrosc Leech1 Leech2 Leech3 Leech4 Leuco Limoniindet Lumbri Lymnae
#> 2      0       0      0      0      0      0     0           0      0      0
#> 3      0       0      0      0      0      0     0           0      0      0
#> 4      0       0      0      0      2      0     0           0      0      0
#> 5      0       0      0      0      0      0     0           0      0      0
#> 8      0       0      0      0      0      0     0           0      0      0
#> 9      0       0      0      0      0      0     0           0      0      0
#> 1      0       0      0      0      2      0     0           0      0      0
#> 7      0       0      0      0      0      0     0           0      0      0
#> 37     0       0      0      0      0      0     0           0      1      0
#> 38     0       0      0      0      0      0     0           0      6      0
#> 47    15       0      0      0      0      0     0           0    167      0
#> 24    16       0      1      0      0      0     0           0      3      0
#> 46    19       0      1      0      0      0     0           0    133      0
#> 43     6       0      0      0      0      0     0           0     24      0
#> 45    11       1      0      0      0      0     0           0     60      0
#> 50     5       0      0      0      0      0     0           0    104      0
#> 40     0       0      1      0      1      0     0           0      4      0
#> 42     2       0      0      0      0      0     0           0      2      0
#> 14    12       0      1      0      0      0     0           0      5      0
#> 49    22       0      0      0      0      0     0           0      6      0
#> 51    25       0     10      0      0      0     0           0     33      0
#> 29    15       0      2      0      0      0     0           0      0      0
#> 30     3       0      3      1      2      0     0           0      3      0
#> 31     5       0      2      0      0      0     0           0     18      0
#> 33     2       0      0      1      0      0     0           0      9      0
#> 6      0       0     22      0      0      0     0           0      0      0
#> 41     5       0      1      0      0      0     0           0      1      0
#> 26     3       0      0      0      0      4     0           0     12      0
#> 27     7       0      2      0      0      0     0           0      4      0
#> 34     8       0      0      0      0      0     0           0      1      0
#> 35     5       0      0      0      0      0     0           0      7      0
#> 10     1       0      0      0      0      0     0           0     56      0
#> 15     6       0      5      0      0      0     0           0      8      0
#> 16    37       0      2      0      0      0     0           0     19      0
#> 17     6       0     10      1      0      0     0           0    239      1
#> 18    36       0      4      0      0      0     0           0      7      0
#> 19     4       0     12      2      0      0     0           0      1      0
#> 20    41       0      1      0      4      0     0           0     19      1
#> 21   480       0      2      0      0      0     0           4      2      0
#> 22     5       0      0      0      0      0     0           0      1      0
#> 25    29       0     36      1      0      0     1           0     46      1
#> 28     3       1      0      0      0      0     0           0      7      0
#> 32     1       0      1      0      0      0     0           0    188      0
#> 36    18       0      0      0      0      0     0           0      3      0
#> 48    21       0     42      6      0      0     0           0     74      0
#> 13     4       0      1      0      0      0     0           0      6      0
#> 12    23       0      0      0      0      0     0           0      8      0
#> 11     7       0      3      3     35      0     0           0     57      0
#> 23     5       0      4      0      0      0     0           0     23      0
#> 39     1       0     26     10      0      0     0           0     54      0
#> 44    60       0      0      1      0      0     0           0      5      0
#>    Maya Molo1 Molo2 Morto Musci5 Musci6 Musci7 Musci4 Musci1 Musci2 Musci3
#> 2     0     1     0     0      0      0      0      1     11      0      0
#> 3     0     0     0     0      0      0      0      0      0      0      0
#> 4     0     0     0     0      0      0      0      0      8      0      0
#> 5     0     0     0     0      0      0      0      1      0      0      0
#> 8     0     0     1     0      0      0      0      0      2      0      0
#> 9     0     0     0     0      0      0      0      0      0      0      0
#> 1     0     0     1     0      0      0      0      0      0      0      0
#> 7     0     0     0     0      0      0      0      0      0      0      0
#> 37    0     0     0     0      0      0      0      0      0      0      0
#> 38    0     1     0     0      0      0      0      0      0      0      0
#> 47    0     0     0     0      0      0      0      0      2      0      0
#> 24    0    11     0     1      0      0      0      3      2      0      0
#> 46    0     2     0     0      0      0      0      0      1      0      0
#> 43    0   120     0     0      0      0      0      0      6      3      7
#> 45    0    26     0     2      0      0      1      0      0      1      0
#> 50    0    24     5     5      0      0      0      0      0      0      0
#> 40    0     1     0     1      0      0      0      0      0      0      0
#> 42    0     3     0    12      0      0      0      0      1      0      0
#> 14    0     7     0   277      0      0      0      0      1      0      0
#> 49    0     1     0    14      0      0      0      0      1      0      0
#> 51    0    10     0    28      0      0      0      0      0      0      0
#> 29    0     2     0    54      0      0      0      0      0      0      0
#> 30    0    20     0     8      0      0      0      0      0      0      1
#> 31    0     9     0     4      0      0      1      0      0      0      0
#> 33    0    15     0     4      0      0      0      0      0      0      0
#> 6     0     0     0     0      0      0      0      0      0      0      0
#> 41    2     7     0    83      0      0      0      0      0      0      0
#> 26    0     7     0     0      0      0      0      0      0      0      0
#> 27    0    16     0     0      0      0      0      1      0      0      0
#> 34    0    14     0    45      0      0      0      0      1      0      0
#> 35    0     3     0     5      0      0      0      0      0      0      0
#> 10    0     2     0    30      0      0      0      0      2      0      0
#> 15    0    10     0     0      0      0      0      0      2      0      0
#> 16    0    20     0     0      0      0      0      0      2      0      0
#> 17    0    24     0     0      0      0      0      0      3      0      0
#> 18    0     8     0     1      0      0      0      0      0      0      0
#> 19    0    19     0     0      0      0      0      0      0      0      0
#> 20    0     0     0     0      0      0      0      0      0      0      0
#> 21    0     0     0     0      0      0      0      1     15      0      0
#> 22    0     4     0     2      0      0      0      1      0      0      0
#> 25    0     0     0     0      0      0      0      0      0      0      0
#> 28    0    22     0    88      0      0      0      0      0      0      0
#> 32    0     1     0     0      0      0      0      0      0      0      0
#> 36    0    11     0     0      0      0      0      0      0      0      0
#> 48    0     0     0     0      0      0      0      0      0      0      0
#> 13    0    10     0    14      0      0      0      0      3      3      2
#> 12    0     0     0     0      0      0      0      0      0      0      0
#> 11    0     0     0     0      1      3      0      3     18      0      0
#> 23    0    11     0    95      0      0      0      0     15      0      2
#> 39    0     1     0     0      0      0      0      0      7      0      0
#> 44    0     1     0     2      0      0      0      0      0      0      2
#>    Naid1 Naid2 Naid3 Nectop Nema Neoel1 Neoel2 Neot Nepti Nona1 Ochro Ortho
#> 2     39     0     0      0    2      0      0    0     0     0     0    72
#> 3      0     0     0      0    0      0      0    0     0     0     0     0
#> 4     32     0     0      0    4      0      1    0     0     0     0    85
#> 5      0     0     0      0    0      0      0    0     0     0     0     7
#> 8      0     0     0      0    2      0      0    0     0     0     0    43
#> 9      0     0     0      0    0      0      0    0     0     0     0     2
#> 1     19     0     0      0   16      0      0    0     0     0     0   109
#> 7      9     0     0      0   29      1      5    0     0     0     4   111
#> 37     0     0     0      0    1     87      2    0     0     0     0     3
#> 38     0     0     0      0    1      7      1    0     0     0     1     1
#> 47     0     0     0      0    0     27      5   13     0     0     0    97
#> 24     0     1     0      2    1    301     16    0     2     1     0    36
#> 46     0     0     0      1    0     52     12    7     0     0     0   306
#> 43    10     2     0      3    1     34      2    1     0     0     0   746
#> 45     2     0     0      0    2     14      1   14     0     0     0   273
#> 50     2     0     0      2    2    122     13    0     0     0     0   190
#> 40     1     0     0      0    0     23      3    4     0     0     0     5
#> 42     0     0     0      0    1     26      5    2     0     0     5    66
#> 14     0     0     0      1   11     43      8    0     0     0     3   605
#> 49     2     0     0      0    2     17      0    0     0     0    81   353
#> 51    22    26     0      0    0     19     11   12     0     0    60   708
#> 29     3     0     0      0    2      3      0    0     0     0     3   579
#> 30     8     0     0      0    2      5      2    2     0     1     0  1920
#> 31     8     0     0      0    7      6      1    4     0     0     0  2372
#> 33     2     0     0      0   29      3      3    1     0     0     0  2330
#> 6     37     0     0      0    2     18     30    0     0     0    19   414
#> 41     2     0     0      0    0     46      7    7     0     0    12    90
#> 26     0     0     0      0    1     23      0    0     0     0     1   182
#> 27     0     0     0      0    2    157      0    0     0     0     0   228
#> 34     0     0     0      0    0     98      2    1     0     0     0  1442
#> 35     0     0     0      0    1     17      0    3     3     0     0  9237
#> 10     0     0     0      0   20      1      0    0     0     0     0   189
#> 15    29     0     0      0    8    138     21    0     1     0    31   629
#> 16     2    10     0      0    3      7      0    0     0     0    80  1618
#> 17    15     0     0      0    4      1      0    0     0     0     1   466
#> 18     0     0     0      0    4     23      1  109     0     0     3  2922
#> 19     0     1     0      0    0    145      1    0     0     0     0   626
#> 20     3    16     0      0    4     43      0    0     0     0     0   503
#> 21     0     0     0      0    3      6      0    0     0     0     0    49
#> 22     2     0     0      1    0     27      0    0     0     0     1   338
#> 25    13     0     0      0    9      0      0    0     0     0     0   531
#> 28     1     3     0     10    0     35      7  144     0     0    10   961
#> 32     7     0     0      0    1      0      0    0     0     0     0    21
#> 36     2     0     0      0    9    174     12    8     0     0     0  2332
#> 48     5     0     0      0    5     19      0    1     0     0     0   519
#> 13     2     0     0      0    2      7      1    0     0     0    18   704
#> 12     5     0     0      0    2      1      0    0     0     0     7   540
#> 11    49    10    12      0    1      3      1    0     0     0     0   848
#> 23     7     0     0      0    0     53     11    0     0     0     0   520
#> 39     8     0     0      0    1     11      1    0     0     0     0     7
#> 44     0     4     0      0    0     15      0    0     0     0     0   230
#>    Ostra Podo1 Podo2 Podo3 Podo4 Priono1 Priono2 Priono3 Schoe Simu1 Sphae
#> 2      0    24     0     4     1       0       0       0     0   124     0
#> 3      0    16     0    28     0       0       0       0     0     0     0
#> 4      0   177     0     2     2       0       0       0     0    18     0
#> 5      0    13     0    71     1       0       0       0     0     0     0
#> 8      0    46     0     3     0       0       0       0     0     3     0
#> 9      0    49     0    20    14       0       0       0     0     0     0
#> 1      0    20     0     1     5       0       0       0     0     9     0
#> 7      0     3     0     1     0       2       0       0     0    21     0
#> 37     0     0     0     0     0       0       0       0     0     4     0
#> 38     2     0     0     2     0       0       0       0     0    15     0
#> 47     0     7     0    27     0       7       0       0     0    60     0
#> 24    52    15     1    19     0      61       8       0     0    67     0
#> 46     2     8     0     4     0       5       0       0     0    49     1
#> 43     0    55     0   176     8       8       4       0     0    79     0
#> 45     2    26     0    34     0      19       2       0     0    29     0
#> 50     0   151     0   521     0      22       3       2     0   101     0
#> 40     0     0     0     0     0       4       1       0     0     3     0
#> 42     0     0     0     0     0       2       0       0     0     2     0
#> 14     0    12     0    10     0       5       0       0     0    20     3
#> 49     5     7     0     8     0       0       0       0     0    24     2
#> 51     3     9     0     6     0       4      12       0     0    18     0
#> 29     1     6     0     1     0       0       0       0     1     5     0
#> 30     4     2     0    24     0       2       0       0     0     3     2
#> 31     1     1     0    13     0       1       0       0     1     3     0
#> 33     0     0     0     3     0       1       0       0     0     4     0
#> 6      0    37     0    18     2       4       0       0     0    11     0
#> 41     2     1     0     0     0       0       0       0     0     0     0
#> 26   126     1     0     1     0      37       2       0     0   127     0
#> 27    17     7     0     0     0      16       0       0     0    11     0
#> 34     0     1     1    51     0      11       1       0     0    20     0
#> 35     0     8     0     9     0      15       0       0     0    11     0
#> 10     0     0     0    10     0       0       0       0     0    31     0
#> 15     0     4     0     0     0       3       0       0     0    12     0
#> 16     0     0     0     2     0       8       0       0     0    22     0
#> 17     6     1     0     0     0       0       0       0     0    26     7
#> 18    30     1     0     1     0     168       4       0     0    21     0
#> 19     5     1     0    26     0      66       2       0     0   168     0
#> 20    17     2     0     1     0       1       0       0     0   167     0
#> 21     1   243     0     0     0       0       0       0     0     0     0
#> 22     5     2     0     4     0      22       3       0     0    23     1
#> 25  1804     0     0     0     0       1       0       0     0   148     2
#> 28     2     0     0    60     0      16       0       0     0    13     0
#> 32     1     0     0     0     0       0       0       0     0     1     0
#> 36     4     1     0     7     0      69      14       0     0   131     0
#> 48    96     1     2     0     0      12       0       0     0    13     0
#> 13     0     1     0     3     0       1       0       0     0    76     2
#> 12     0     0     0     0     0       0       0       0     0     0     0
#> 11    76     3     0     0     0       0       0       0     0     0    21
#> 23     4    10     0     8     0       9       1       0     0     5     3
#> 39    19     0     0     0     0       3       0       0     0     0    12
#> 44    29    30     0     8     0       4       0       0     0    26     3
#>    Staphy1 Staphy2 Stilo1 Sync1 Tanyp Tipu Trichoco
#> 2        1       0      0     0     0    0        0
#> 3        0       0      0     0     0    0        0
#> 4        0       0      0     0     0    0        0
#> 5        0       0      0     0     0    0        0
#> 8        0       0      0     0     0    0        0
#> 9        1       0      0     0     0    0        0
#> 1        0       1      0     0     0    1        0
#> 7        0       0      0     0     0    0        0
#> 37       0       0      0     0     0    0        0
#> 38       0       0      0     0     0    0        0
#> 47       0       0      0     0     0    0        0
#> 24       0       0      0     0     0    0        0
#> 46       0       0      0     0     3    0        0
#> 43       0       0      0     0    17    0        0
#> 45       0       0      0     0     2    0        0
#> 50       0       0      0     0     4    0        0
#> 40       0       0      0     0     0    0        0
#> 42       0       0      0     0     0    0        0
#> 14       0       0      0     1    22    0        0
#> 49       0       0      1     1     0    0        0
#> 51       0       0      0     0     8    0        0
#> 29       0       0      0     0     3    0        0
#> 30       0       0      0     0    13    0        0
#> 31       0       0      0     0     4    0        0
#> 33       0       0      0     0     1    0        0
#> 6        0       0      0     0     1    0        0
#> 41       0       0      0     0     0    0        0
#> 26       0       0      0     0     3    0        0
#> 27       0       0      0     0    11    0        0
#> 34       0       0      0     0    14    0        0
#> 35       0       0      0     3    68    0        0
#> 10       0       0      0     0     7    0        0
#> 15       0       0      0     0    16    0        0
#> 16       0       0      0     0    16    0        0
#> 17       0       0      0     0     2    0        0
#> 18       0       0      0     0     7    0        0
#> 19       0       0      0     0     2    0        0
#> 20       0       0      0     0   130    0        0
#> 21       0       0      0     0     0    0        4
#> 22       0       0      0     0     0    0        0
#> 25       0       0      0     0     0    0        2
#> 28       0       0      2     1   241    0        0
#> 32       0       0      0     0     0    0        0
#> 36       0       0     10     0     8    0        0
#> 48       0       0      0     0    44    0        0
#> 13       0       0      0     2     5    0        0
#> 12       0       0      0     0     0    0        0
#> 11       0       0      0     0     1    0        0
#> 23       0       0      0     0     0    0        0
#> 39       0       0      0     0     0    0        0
#> 44       0       0      0     0     2    0        0

Created on 2020-03-24 by the reprex package (v0.3.0)

That is not copy/paste friendly, please read the guide I gave you before and post a proper reproducible example.

Super, here is the link to the file:

Thank you very much for your help @andresrcs

I still can't reproduce, I get the expected results, maybe your problem is the way you are reading the data.

url <- "https://www.dropbox.com/s/uv3a9yutfxmc8oz/MBC_SPP_ALL.csv?dl=1"
spe <- read.csv(url)
rowSums(spe[,-1])
#>  [1]   287    44   340    93   107    87   214   268   112    58   809  1654
#> [13]  1233  2686   994  2783   226   363  1510  1497  1461  1028  2969  2823
#> [25]  2595   760   645  2076  1285  2126 10050   534  1694  4202  1379  4135
#> [37]  1407  3855  4049  1664  4395  3091   232  3367  1458  1732  2400  2116
#> [49]  1833   555  2797
rowSums(spe[,-1] > 0)
#>  [1] 16  2 15  5  9  6 17 17 10 15 20 34 28 35 32 28 21 26 33 30 31 27 36 35 26
#> [26] 20 25 23 25 30 27 19 26 27 25 34 26 25 17 28 22 37 14 32 26 34 16 28 31 18
#> [51] 22

Oh :flushed: Yes, the problem then might be the way I was reading the data, or maybe the functions that I was using? I don’t think that’s the case, but, any way, thanks a lot for your help and time :smiley:
When I read the file from my files as:
spe<-(read.table("~/Dropbox/Docs Redro/Paper Tesis MBC/MBC_SPP_ALL.csv", sep=",", header=TRUE, row.names=1))
I still get the same mistakes on my sums and counts, but when I read it like you did url <- "https://www.dropbox.com/s/uv3a9yutfxmc8oz/MBC_SPP_ALL.csv?dl=1"
spe <- read.csv(url)
I get the expected results as from excel counts and sums, kind of strange.

When you read this way you don't get the row names on the first column so there is no need to exclude the first column (spe[,-1])

Ah, ok, still a lot to learn in R.
Thank you a lot @andresrcs