[R] Difficulty in caper: Error in phy$node.label[which(newNb > 0) - Ntip]

Peter Ehlers ehlers at ucalgary.ca
Thu Mar 7 18:35:30 CET 2013


On 2013-03-06 07:49, Nicole Thompson wrote:
> Hello,
>
> I'm doing a comparative analysis of mammal brain and body size data.
> I'm following Charlie Nunn and Natalie Cooper's instructions for
> "Running PGLS in R using caper".
>
> I run into the following error when I create my comparative dataset,
> combining my phylogenetic tree (mammaltree) and taxon measures
> (mammaldata):
>
> "Error in phy$node.label[which(newNb > 0) - Ntip] : only 0's may be
> mixed with negative subscripts"
>
> My full script is provided at the bottom.
>
> I have looked at the caper manual by David Orme to understand how
> comparative.data() constructs the dataset, but still cannot interpret
> the error. Many thanks to anyone who could provide me with insight.
>
> Nicole Thompson
> E3B Columbia University
>
>
>
>> library(caper)
>
> Loading required package: ape
>
> Loading required package: MASS
>
> Loading required package: mvtnorm
>
>>
>
>> mammaldata <-read.csv("R.Mammal_data.csv", header = TRUE)
>
>> mammaltree <-read.nexus("BEphylotree.nex")
>
>> mammal <- comparative.data(phy = mammaltree, data = mammaldata, names.col = Taxon, vcv = TRUE, na.omit = FALSE, warn.dropped = TRUE) #names.col?
>
> Error in phy$node.label[which(newNb > 0) - Ntip] : only 0's may be
> mixed with negative subscripts

Looks to me like 'which(newNb > 0) - Ntip' evaluates to a
vector that has both positive and negative elements.
Like this:

   x <- 1:5
   x[c(-2,-4)] ## ok
   x[c(-2, 0)] ## ok
   x[c(-2, 4)] ## generates your error

Peter Ehlers

>
>
>
>
>
> --
> Nicole A Thompson
> E3B Columbia University, NYCEP
> nat2103 at columbia.edu
> 480.522.4212
>



More information about the R-help mailing list