r - 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 行并计算数据,因为只有几百列。
它似乎在大约中点处“切断”,按列。
解决方案
推荐阅读
- python - 卸载 Python 时出现错误 0x80070643
- javascript - 为什么“Col”在 React 引导程序中不起作用?
- python - 为什么我的页面中表单提交数量的计数器不起作用(烧瓶)
- hibernate - 如何从现有数据库生成 Spring 数据实体
- git - 删除已经推送到远程的旧 git commit
- r - 如何在反应式环境中将 dplyr::filter 与输入值一起使用?
- javascript - 为什么在 CSS 中,图像只在边框周围四舍五入?
- android-studio - 为什么我的活动在尝试搜索回收站视图时会崩溃?
- jestjs - 使用什么正则表达式从 gitlab ci 捕获笑话文本代码覆盖率报告
- robot - 如何在没有硬件的情况下使用 xArmStudio 进行模拟?