Re: [R] question about getting things out of an lapply

2011-07-10 Thread Annemarie Verkerk
Dear Josh, thank you so much for working this out for me - it works really well now! My only remaining problem is that I can't seem to plot the gradients to color.edge in plot.phylo() for my tree, but I've asked the relevant list (R-sig-phylo) for some troubleshooting with that. Many thanks

Re: [R] question about getting things out of an lapply

2011-07-07 Thread Joshua Wiley
Dear Annemarie, Look at what you are passing to your function: lapply(tree$edge, print) I am guessing you want to be passing: lapply(1:nrow(tree$edge), print) so that you are using each row of tree$edge. Also, take a look at the code below for some examples of ways you can simplify (and vastl

Re: [R] question about getting things out of an lapply

2011-07-07 Thread Annemarie Verkerk
Dear Josh, thanks for pointing this out - the idea behind writing this function is plotting gradients on branches of phylogenetic trees - 'tree' refers to a phylogenetic tree. It's easy to create a random phylogenetic tree in R: library(ape) library(plotrix) rtree(15) -> tree This gives you

Re: [R] question about getting things out of an lapply

2011-07-06 Thread Joshua Wiley
Dear Annemarie, Can you replicate the problem using a madeup dataset or one of the ones built into R? It strikes me as odd to pass tree1$edge directly to lapply, when it is also hardcoded into the function, but I do not have a sense exactly for what you are doing and without data it is hard to pl

[R] question about getting things out of an lapply

2011-07-06 Thread Annemarie Verkerk
Dear R-help subscribers, I have a quite stupid question about using lapply. I have the following function: create.gradient <- function(i){ colorgrad01<-color.scale(seq(0,1,by=0.01), extremes=c("red","blue")) tree1$edge[i,1] -> x tree1$edge[i,2] -> y print(x) print(y) all2[x] -> z all2[y] -> z2