-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making the CompressedList more widely usable #11
Comments
An Making CompressedList non-virtual (and requiring Vector for |
Note that
with
Personally I prefer to stick to
|
I do like the symmetry, simplicity and safety of the |
Indeed, I didn't even know about My motivation for library(IRanges)
X <- DataFrame(statistic=runif(100), more_stats=rnorm(100))
Y <- split(X, sample(LETTERS, 100, replace=TRUE))
# List-style getter/setter:
Y$statistic <- Y$statistic * 2
# Hypothetical DataFrame-style getter/setter:
unlist(Y)$statistic <- log2(unlist(Y)$statistic) The Z <- unlist(Y)
Z$statistic <- log2(Z$statistic)
Y <- relist(Z, Y) A recursive basic <- sample(LETTERS, 100, replace=TRUE)
nest1 <- CharacterList(split(basic, sample(10, length(basic), replace=TRUE)))
# Create a list of CompressedList instances (if CompressedList() existed)
nest2 <- CompressedList(split(nest1, sample(3, length(nest1), replace=TRUE)))
# recursive=TRUE as default
unlist(nest2) <- paste0("WHEE", unlist(nest2)) |
I've been playing around with the
CompressedList
subclasses for representing some complex data types and I've really come to like it. I've been thinking of ways to make it more generally usable by both end-users and other developers, and I've got a few wish-list elements:Access to
unlistData
andpartitioning
. End-users would then be able to execute arbitrary unary operations on the underlying data while preserving the partitioning, like:unlistData<-
could even beunlist<-
, if one were willing to introduce that concept. I don't mind ifpartitioning
is getter-only; this would still be very useful for downstream functions that need to be list-aware yet don't want to create an intermediatelist
for efficiency purposes.Non-virtual
CompressedList
class. I don't understand the motivation for makingCompressedList
virtual. From a representation perspective, a general concrete class would be useful if we could store any vector-like entity inunlistData
. In fact, I ran into the case where I wanted to store aCompressedCharacterList
asunlistData
, effectively making aCompressedCompressedCharacterListList
! I don't expect to be able to call many methods on this thing - other than the proposedunlistData
andpartitioning
, and maybeunlist
- I just want to use it for storage without needing to write an explicit subclass. A generalCompressedList
class would serve this purpose, and is better than the alternative of falling back to aSimpleList
(which takes a noticeable time to generate).A more careful
unlist
. If we do allow a generalCompressedList
class, theunlist
method should probably take heed ofrecursive=TRUE
and applyunlist
on theunlistData
slot.I'm happy to chip in with a PR if these sound like good ideas.
The text was updated successfully, but these errors were encountered: