ggobi / plumbr

Mutable dynamic data structures for R
18 stars 2 forks source link

adding a new column to a mutaframe #2

Closed yihui closed 13 years ago

yihui commented 13 years ago

I think this might be a bug, but I do not know how to fix it:

y = mutaframe(data.frame(a=1))
add_listener(y,function(i,j) print(j))
y$a = 3  # get 'a'
y$b = 2  # Problem 1: get NULL here, should be 'b'
add_listener(y, function(i, j) print(y[j]))
y$c = 5 # Problem 2: error
y  # error
lawremi commented 13 years ago

The first problem is not a bug, at least as designed. The event handler is passed NULL when the number of columns changes. We can discuss this again, but it's already been discussed at length. The second problem was a bug in the coercion to data frame in the zero column case. It's fixed. Thanks.

yihui commented 13 years ago

I'm OK with NULL. Thanks!

Then what about this error?

y = mutaframe(data.frame(a=1))
add_listener(y, function(i, j) print(as.data.frame(y)))
y$b = 5 #  error
hadley commented 13 years ago

That example works for me with a version of plumbr I just reinstalled from git.

yihui commented 13 years ago

OK, it works now