Skip to content
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

table input #20

Closed
ggrothendieck opened this issue May 20, 2021 · 4 comments · Fixed by #49
Closed

table input #20

ggrothendieck opened this issue May 20, 2021 · 4 comments · Fixed by #49
Assignees

Comments

@ggrothendieck
Copy link

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)
@jwood000
Copy link
Owner

@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

@ggrothendieck
Copy link
Author

PermutateGeneral could be turned into an S3 generic with table and default methods (and maybe others in the future?).

@jwood000 jwood000 self-assigned this Mar 17, 2022
@jwood000
Copy link
Owner

jwood000 commented Oct 22, 2023

@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: 9257689

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

@jwood000
Copy link
Owner

I've further expanded the use of S3 methods throughout the package. I added a link to the branch under the Development section.

@jwood000 jwood000 linked a pull request Nov 30, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants