Re: [R] Working with tables with missing levels

2009-07-27 Thread Andre Nathan
On Mon, 2009-07-27 at 16:34 -0300, Henrique Dallazuanna wrote: > Try this: > > t1 <- prop.table(table(factor(c(0,0,2,4,4), levels = 0:4))) > t2 <- prop.table(table(factor(c(0,2,2,2,3), levels = 0:4))) Is there a way to do this given an already existing table? The problem is that I actually build

Re: [R] Working with tables with missing levels

2009-07-27 Thread Henrique Dallazuanna
Try this: t1 <- prop.table(table(factor(c(0,0,2,4,4), levels = 0:4))) t2 <- prop.table(table(factor(c(0,2,2,2,3), levels = 0:4))) On Mon, Jul 27, 2009 at 4:21 PM, Andre Nathan wrote: > Hello > > I'm trying to write a function to calculate the relative entropy between > two distributions. The da

Re: [R] Working with tables with missing levels

2009-07-27 Thread Tal Galili
Hi Andre, Just about expending the table, The way you could do this is by using factors, for example: t1 <- prop.table(table(factor(c(0,0,2,4,4 t2 <- prop.table(table(factor( c(0,2,2,2,3 The rest is for more knowledgeable people then me to say... On Mon, Jul 27, 2009 at 10:21 PM, And

[R] Working with tables with missing levels

2009-07-27 Thread Andre Nathan
Hello I'm trying to write a function to calculate the relative entropy between two distributions. The data I have is in table format, for example: > t1 <- prop.table(table(c(0,0,2,4,4))) > t2 <- prop.table(table(c(0,2,2,2,3))) > t1 0 2 4 0.4 0.2 0.4 > t2 0 2 3 0.2 0.6 0.2 The re