r - lm.fit 中的错误:“y”中的 NA/NaN/Inf。当尝试转换为对数刻度时
问题描述
我正在尝试通过使用 vegdist 在基础 R 中绘制线性回归模型,然后通过转换为对数刻度来拟合它们 我的数据框:
> str(un_sap.bray)
'dist' num [1:72390] 0.53 0.228 0.48 0.124 0.648 ...
- attr(*, "Size")= int 381
- attr(*, "Labels")= chr [1:381] "als1" "als2" "als3" "als4" ...
- attr(*, "Diag")= logi FALSE
- attr(*, "Upper")= logi FALSE
- attr(*, "method")= chr "bray"
- attr(*, "call")= language vegdist(x = un_sap.otu, method = "bray")
我的代码:这些所有代码都在工作
> un_sap.bray <- vegdist(un_sap.otu,"bray")
> un_sap.xy.dist=dist(un_sap.xy[,c('x','y')])
> plot(log(un_sap.xy.dist),log(un_sap.bray))
> DDR.un_sap.lm=lm(log(un_sap.bray)~log(un_sap.xy.dist))
> summary(DDR.un_sap.lm)
> abline(DDR.un_sap.lm,col=2)
然后我尝试在 lm() 拟合散点图出现错误后计算 1-vegdist()
> un_sap.bray <- 1-vegdist(un_sap.otu,"bray") #change to similarity
> un_sap.xy.dist=dist(un_sap.xy[,c('x','y')])
> plot(log(un_sap.xy.dist),log(un_sap.bray))
> DDR.un_sap.lm=lm(log(un_sap.bray)~log(un_sap.xy.dist))
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in 'y'
我检查了数据中的 NA
> any(is.na(log(un_sap.bray)))
[1] FALSE
> any(is.na(log(un_sap.xy.dist)))
[1] FALSE
我怎样才能解决这个问题?有人能帮我吗...
解决方案
推荐阅读
- java - 根据编译时设置变量
- node.js - 使用 Redis 和 Nodejs 创建 RESTful API
- python - Python:无法将 wav 转换为 flac
- python - Python:使用 tkinter 递增类属性
- android - 如何发送对新活动的响应?
- java -
我遇到了 Primefaces 的 selectMany 组件的问题。
我检查了 selectManyMenu 中的一些选项,但在 bean bReservarPista 中返回了 arrayList 大小 0
<p:selectManyMenu id="manyHoras" value="#{
- python - 如何检查用户的输入是否有效 Python
- vb.net - 如何在 Visual Studio 2015 中对 Crystal Report 进行排序
- kubernetes - Google Kubernetes Engine 上的 Traefik 错误
- java - Eclipse Gradle 项目中突然丢失依赖项