Hi there,

I'm working with an object whose internal data representation is very
different from a data.frame (data is stored as a list of big.matrix objects
from the bigmemory package) but to which I'd like to give users
data.frame-like access. I've implemented names very easily as follows:

setMethod("names", signature = "my.dataset", definition = function (x) {
  x@colnames
})

Now I'd like to implement `names<-` analogously.

Of course the following does not work, because only the local copy of the
dataset is changed:

setMethod("names<-", signature = "my.dataset", definition = function (x,
value) {
  x@colnames <- value
})

Following a suggestion I found in the list archives, I thought it might be
worthwhile to try something like the following:

setMethod("names<-", signature = "my.dataset", definition = function (x,
value, env = parent.frame()) {
  with(parent.frame(), x@colnames <- value)
})

But of course because `names<-` is primitive, if I try to redefine the
generic function as follows so I can pass it another argument:

setGeneric("names<-", def = function (x, value, ...) {
standardGeneric("names<-") })

Then I get the following error:

Error in setGeneric("names<-", def = function(x, value, ...) { :
  ‘names<-’ is a primitive function;  methods can be defined, but the
generic function is implicit, and cannot be changed.

Any advice on ways around this, or other approaches to the problem, would
be very welcome!

Thanks,

Max



Max Gasner
Navia Systems | 415 413 3821

	[[alternative HTML version deleted]]

