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

Nicole Thompson gavago at gmail.com
Fri Mar 8 02:12:07 CET 2013


Thank you, Peter, for your response.

I can see then that comparative.data() is performing some operation
that calls an invalid subset of either my phylo or data file
(mammaldata or mammaltree).

It would be helpful to understand what "newNb" is, as
comparative.data() creates it while constructing the comparative
dataset. I'm guessing Ntip is the taxa I've included in my mammaldata.
Perhaps newNb is the number of nodes inside the mammaltree and the
error occurs because the taxa and tree nodes don't match well?

If anyone has similar experience with comparative.data(), I would
greatly appreciate your insight.

Thank you.
Nicole

On Thu, Mar 7, 2013 at 12:35 PM, Peter Ehlers <ehlers at ucalgary.ca> wrote:
> 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
>>
>



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



More information about the R-help mailing list