Skip to content

matching lists

3 messages · Manoel Silva, PIKAL Petr, Baptiste Auguie

#
Hi

lapply should do it if values is a data frame with first column of names 
and second column numbers.

lapply(v, function(x) values[match(x, values[ ,1]), 2])

Regards
Petr


r-help-bounces at r-project.org napsal dne 14.04.2009 14:01:50:
"three",
will
http://www.R-project.org/posting-guide.html
#
Try this,

numbers <- c("one","two","three","four")
values <- c(10,20,30,40)
v <- list(sample(numbers,3),sample(numbers,2))
v
sapply(v,function(.l) values[match(.l, numbers)] )


HTH,

baptiste
On 14 Apr 2009, at 13:01, Manoel Silva wrote:

            
_____________________________

Baptiste Augui?

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag