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

Figure out why gather() is so much slower than melt() #18

Closed
hadley opened this issue Aug 12, 2014 · 1 comment
Closed

Figure out why gather() is so much slower than melt() #18

hadley opened this issue Aug 12, 2014 · 1 comment

Comments

@hadley
Copy link
Member

hadley commented Aug 12, 2014

http://stackoverflow.com/questions/24880835

@hadley
Copy link
Member Author

hadley commented Aug 22, 2014

Looks like it's the non-standard eval:

library(microbenchmark)
iris1 <- iris[sample(1:nrow(iris), 1e4, replace = T), ] 

microbenchmark(
  melt = reshape2::melt(iris1,id.vars="Species"), 
  gather = tidyr::gather(iris1, variable, value, -Species),
  gather_ = tidyr::gather_(iris1, quote(variable), quote(value), c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"))
)
Unit: milliseconds
    expr  min   lq median   uq   max neval
    melt 2.41 2.66   3.15 4.87 52.49   100
  gather 3.97 4.98   6.40 6.82  8.41   100
 gather_ 2.43 2.67   3.07 4.94 51.42   100

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