首页 > 解决方案 > Rowsums 没有正确添加?

问题描述

我有一个包含一堆零和一的存在缺席数据库,但是当我使用行和时,它似乎只计算一部分数据然后停止。这是我的代码

site_matrix=read.csv("TriassicMatrix1.csv", header=T) # create object called site_matrix
summary(site_matrix) # get summary
head(site_matrix) # check out first few columns
tail(site_matrix) # check out last few columns
View(site_matrix) # take a look at whole dataset in new window

# here's the problematic line 

spp_rich=rowSums(site_matrix [,2:25]) # generate richness for sites

有 25 行数据,它给了我不正确的输出,例如建议第一行只有 4 次出现,而它有 7 次。

我尝试将其更改为 [,1,25] 并且它不起作用,因为第 1 行是我的标题行,所以我知道不是那样。当我查看 R 中的数据时,我可以很容易地转到第 2 行并计算数据,因为只有几百列。

它似乎在大约中点处“切断”,按列。

标签: r

解决方案


推荐阅读