My guess is that you are dimly remembering stack(.)
t <- list(A=c(4,1,4),B=c(3,7,9,2))
> stack(t)
values ind
1 4 A
2 1 A
3 4 A
4 3 B
5 7 B
6 9 B
7 2 B
If you needed the internal factor of ind that is possible as well
> as.numeric(stack(t)$ind)
Dear Marco,
Try this:
# Data
t1 <- list(A=c(4,1,4),B=c(3,7,9,2))
# Processing
res=data.frame(
t1=do.call(c,t1),
levels=rep(c(1,2),do.call(c,lapply(t1,function(x) length(x
)
rownames(res)=NULL
res
HTH,
Jorge
On Tue, Nov 18, 2008 at 10:15 PM, Blanchette, Marco <
[EMAIL PROTECTED]> wrote:
I am pretty sure that I came across a function that creates a vector of levels
from a list but I just can't remember.
Basically, I have something like
> t <- list(A=c(4,1,4),B=c(3,7,9,2))
> t
$A
[1] 4 1 4
$B
[1] 3 7 9 2
And I would like to get something like the following:
t levels
4 1
1 1
4 1
3 matches
Mail list logo