I am trying to pass some code to use the mmap package. I am having a problem accessing data frame columns.
I would like to be able to access data columns with the $ and [[ . Here are the results I get.
> foo <- as.mmap(mtcars) > foo[,'mpg']
Is there a way to get the $ and [[ operators to work with an object with memory mapping, as it would on a regular data frame?
Edit: At the suggestion of Joshua, I added a function for [[
`[[.mmap` <- function(x,...) `[[`(x[],...)
And for $ , which doesn't look particularly elegant, but seems to work.
> `$.mmap` <- function(x,...) { if (...%in%c("storage.mode","bytes","extractFUN","filedesc")){ get(...,envir=x) }else { eval(call('$',x[],substitute(...))) }}
source share