Search code examples
rdataframephylogeny

Creating a compartive object in R from two dataframes for comparitive phylogenetics


I'm trying to read in two dataframes into a comparitive object so I can plot them using pgls.

I'm not sure what the error being returned means, and how to go about getting rid of it.

My code:

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")

Returns error:

> 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

Solution

  • The error here is that I was using a nexus file, although ?comparitive.data does not specify which phylo objects it should use, newick trees seem to work fine, whereas nexus files do not.