table input
This works:
library(RcppAlgos)
x <- c("a", "b", "b")
tab <- table(x)
permuteGeneral(v = names(tab), freq = tab)
but it would be nice if it directly accepted "table" objects.
permuteGeneral(tab)
@ggrothendieck,
Thanks for opening this issue.
I really like the suggestion.
I can think of a few ways of implementing this. For example, we can check to see if the class of v is table. I do have some concerns... mainly, would this be too restrictive. For example, are there other "table" like objects that I would be missing (something like rle). Maybe, it's okay to be restrictive.
Do you have suggestions for a good way of cleanly handling this?
Thanks, Joseph
PermutateGeneral could be turned into an S3 generic with table and default methods (and maybe others in the future?).
@ggrothendieck,
It has been a while since you posted this issue.
I have started to work on this about a half a dozen times over the past couple of years and this is what I currently have: 92576896e51f797106119410431e6ddf6fa21822
I'm not really happy with it... It feels messy. I was thinking I could clean up the R code with a clever function factory implementation, but before I go off deep end I'd like to see what you think.
I have seen many post from you on stackoverflow about this topic and meta-programming in general. I've also looked at many packages with S3 methods such as one you are involved with, zoo.
Thanks, Joseph
I've further expanded the use of S3 methods throughout the package. I added a link to the branch under the Development section.