[R] Is there a sexy way ...?
Rolf Turner
ro||turner @end|ng |rom po@teo@net
Fri Sep 27 05:55:51 CEST 2024
I have (toy example):
x <- list(`1` = c(7, 13, 1, 4, 10),
`2` = c(2, 5, 14, 8, 11),
`3` = c(6, 9, 15, 12, 3))
and
f <- factor(rep(1:3,5))
I want to create a vector v of length 15 such that the entries of v,
corresponding to level l of f are the entries of x[[l]]. I.e. I want
v to equal
c(7, 2, 6, 13, 5, 9, 1, 14, 15, 4, 8, 12, 10, 11, 3)
I can create v "easily enough", using say, a for-loop. It seems to me,
though, that there should be sexier (single command) way of achieving
the desired result. However I cannot devise one.
Can anyone point me in the right direction? Thanks.
cheers,
Rolf Turner
--
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
+64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619
More information about the R-help
mailing list