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:
Dear All,
Here's my problem. I have two lists:
v
[[1]]
[1] "five"
[[2]]
[1] "four"
[[3]]
[1] "three"
[[4]]
[1] "two"
[[5]]
[1] "one"
[[6]]
[1] "six"
[[7]]
[1] "five" "four" "three" "two" "one" "six"
[[8]]
[1] "four" "three" "two" "one" "six"
[[9]]
[1] "three" "two" "one" "six"
[[10]]
[1] "two" "one" "six"
and the other is something like:
values
numbers
five 50
four 40
three 30
two 10
one 10
six 10
I'm trying to get a list similar to "v", but in which the entries
"three", "two", and so on are replaced by the values in the second
list. Any help will be greatly appreciated.
best regards,
Manoel
[[alternative HTML version deleted]]
<ATT00001.txt>
_____________________________
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
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.