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

reinvigorate iapply? #81

Open
r2evans opened this issue Mar 24, 2017 · 0 comments
Open

reinvigorate iapply? #81

r2evans opened this issue Mar 24, 2017 · 0 comments

Comments

@r2evans
Copy link

r2evans commented Mar 24, 2017

On StackOverflow, a recent answer by G. Grothendieck mentioned an old email of yours about an idempotent apply. Have you (would you?) consider adding an iapply to your reshape package?

Perhaps simply:

iapply <- function (X, MARGIN, FUN, ...)  {
	dims <- c((1:length(dim(X)))[!(1:length(dim(X)) %in% MARGIN)], MARGIN)
	res <- apply(X, MARGIN, FUN, ...)

	if (length(dim(res)) == length(dims)) {
		aperm(res, order(dims))
	} else {
		res
	}	
}

(I added the ... to the apply call since I thought it was appropriate, otherwise this is verbatim from your 2006 email.)

Edit: 121d0ff suggests functions were moved to plyr (I find no use of it there), and 6058c3b is what actually removed iapply with no direct mention of why it was removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant