r - 从两个数据框创建 R 中的比较对象以进行比较系统发育
问题描述
我正在尝试将两个数据帧读入一个比较对象,以便我可以使用 pgls 绘制它们。
我不确定返回的错误是什么意思,以及如何摆脱它。
我的代码:
library(ape)
library(geiger)
library(caper)
taxatree <- read.nexus("taxonomyforzeldospecies.nex")
LWEVIYRcombodata <- read.csv("LWEVIYR.csv")
LWEVIYRcombodataPGLS <-data.frame(LWEVIYRcombodata$Sum.of.percentage,OGT=LWEVIYRcombodata$OGT, Species=LWEVIYRcombodata$Species)
comp.dat <- comparative.data(taxatree, LWEVIYRcombodataPGLS, "Species")
返回错误:
> comp.dat <- comparative.data(taxatree, LWEVIYRcombodataPGLS, 'Species')
Error in if (tabulate(phy$edge[, 1])[ntips + 1] > 2) FALSE else TRUE :
missing value where TRUE/FALSE needed
解决方案
这可能来自您的数据集和您的系统发育有一些comparative.data
难以处理的差异(通过错误消息的外观)。
您可以尝试使用以下方法清理数据集和树dispRity::clean.data
:
library(dispRity)
## Reading the data
taxatree <- read.nexus("taxonomyforzeldospecies.nex")
LWEVIYRcombodata <- read.csv("LWEVIYR.csv")
LWEVIYRcombodataPGLS <- data.frame(LWEVIYRcombodata$Sum.of.percentage,OGT=LWEVIYRcombodata$OGT, Species=LWEVIYRcombodata$Species)
## Cleaning the data
cleaned_data <- clean.data(LWEVIYRcombodataPGLS, taxatree)
## Preparing the comparative data object
comp.dat <- comparative.data(cleaned_data$tree, cleaned_data$data, "Species")
但是,正如@MrFlick 所建议的那样,如果没有可重复的示例,很难知道这是否能解决问题。
推荐阅读
- python - 如何在 ib_insync 中获取我的股份数量?
- javascript - Vue.js - 注入一个 v-on 按钮以从来自外部源的静态 html 生成覆盖
- spring - @WebMvcTest - 如何配置安全性以便测试可以运行?
- python - 当我尝试将 sql 表加载到数据框中时,显示数据框中字符串的 NAN 值
- powershell - Azure DevOps 服务器 Invoke-RestMethod 错误:没有为“PUT”请求提供 API 版本
- amazon-web-services - 有没有一种简单的方法来克隆粘合作业,但更改数据库连接?
- python - 如何根据python中的条件从字典中的列表中删除元素
- react-native-push-notification - 当应用程序不工作时,PushNotificationIOS.getInitialNotification() 总是返回 null
- json - 如何替换存储在 JSON 文件中的 JSON 值并在 Rest Assured 测试中使用它
- javascript - XMLhttprequest 不发布(新的)