[Phylobase-devl] [Fwd: Re: labels() and other questions]

Steve Kembel skembel at berkeley.edu
Sun Mar 2 23:20:01 CET 2008


Hi,

> ~  On second or third thought, I think the default should be "tips" --
> I think we should gear things toward end-users, and let the  
> programmers
> among us deal with typing labels(x,"all") instead of labels(x) ... ?

Agreed.

> | To follow up on that why do we have the function hasNodeLabels?
>  ... I think I set up
> all this junk to try to insulate users from internal details --
> this was probably overkill. Also, the people who are testing
> whether an object has labels or not are probably programmers,
> who can handle this construction.
> ~  We could remove them if there's consensus.

I don't feel like the function overload is that bad yet, and this  
would be a function used primarily by programmers, so I'd vote to  
leave the existing function. It's nicer to read/write  
if(hasNodeLabels) than if(length(NodeLabels(foo))== 0).

> How about:
> getnode(phy,x)  which returns a named vector of node numbers;
> if x is an integer, it matches by number, while if x is
> a character, it matches by name?

Combining the getNodeyLabel/getLabelByNode is a great idea.

I went ahead and changed the labels method to return either tip,  
internal node or all labels, depending on the which argument. The  
default is still tips only so it shouldn't break anything. I couldn't  
figure out how to modify the <- method for labels to accept an  
argument, and noticed that currently there's no checking when  
assigning new labels to a phylo4 object, added this to the TODO.

i.e. how can you add an argument for the generic labels<- method, or  
is this even possible:
labels(x) <- c(which="node","Node1","Node2","Node3")

Steve


More information about the Phylobase-devl mailing list