Re: [R] Table to Data Frame

2004-06-10 Thread Adaikalavan Ramasamy
# Generate data universe <- c(0, 0.17, 0.5, 1, 2.5, 3, 4) prob <- c(94, 1, 1, 1, 1, 1, 1)/1000 tab <- list(NULL) for(i in 1:6){ tab[[i]] <- table(sample(universe, 218, prob=prob, rep=TRUE)) } # Re-table all <- unique(unlist(sapply(tab, function(x) names(x retab <- t(sapply( tab, function

Re: [R] Table to Data Frame

2004-06-10 Thread Wolski
Hi! First as Uwe Ligges explained and finally. do.call("rbind",tab) Sincerely Eryk *** REPLY SEPARATOR *** On 6/10/2004 at 10:17 PM Ko-Kang Kevin Wang wrote: >>>[Forwarding on behalf of a colleague] >>> >>>She's got a list with several tables: tab <- list() for(i

Re: [R] Table to Data Frame

2004-06-10 Thread Uwe Ligges
Ko-Kang Kevin Wang wrote: [Forwarding on behalf of a colleague] She's got a list with several tables: tab <- list() for(i in 1:6) { Most easy solution: Make freq[i] a factor with all the levels that may appear. Then all tables have same dimension, e.g.: tab <- lapply(freq, function(x) table(

[R] Table to Data Frame

2004-06-10 Thread Ko-Kang Kevin Wang
[Forwarding on behalf of a colleague] She's got a list with several tables: > tab <- list() > for(i in 1:6) { + tab[[i]] <- table(freq[i]) + } > tab [[1]] 0 0.17 0.3 0.51 2.534 1962515252 [[2]] 0 0.17 0.31 2.534 199136