Re: [R] constructing a data frame from ftable

2010-06-22 Thread Henrique Dallazuanna
Try this: x <- ftable(a.df$DATE, paste(a.df$GENDER, a.df$Co, sep = "-")) as.data.frame(`class<-`(`dimnames<-`(x, list(attr(x, 'row.vars')[[1]], attr(x, 'col.vars')[[1]])), 'matrix')) On Tue, Jun 22, 2010 at 6:50 PM, Erin Hodgess wrote: > Dear R People: > > I have the following data set with the

Re: [R] constructing a data frame from ftable

2010-06-22 Thread Phil Spector
Erin - Perhaps this reproducible example will help: df = data.frame(a=sample(1:20,1,replace=TRUE), b=sample(c('M','F'),1,replace=TRUE), c=sample(LETTERS[1:8],1,replace=TRUE)) tt = as.data.frame(table(df)) tt$bc = paste(tt$b,tt$c,sep='.') tt$b=NULL tt

[R] constructing a data frame from ftable

2010-06-22 Thread Erin Hodgess
Dear R People: I have the following data set with the columns DATE, GENDER, and Co. Co has 8 possible options. > a.df[1:10,] DATE GENDER Co 1 2009-04-16 F Rash 2 2009-04-16 F Other 3 2009-04-16 M Botulinic 4 2009-04-16 M