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

Summarise function with time delta incorrectly mix the unit #2985

Closed
yeyan opened this issue Jul 19, 2017 · 2 comments
Closed

Summarise function with time delta incorrectly mix the unit #2985

yeyan opened this issue Jul 19, 2017 · 2 comments

Comments

@yeyan
Copy link

yeyan commented Jul 19, 2017

stats %>%
  group_by(implementation, message.size) %>%
  summarise(total.size=sum(message.size), 
            begin=min(ts.in), 
            end=max(ts.out), 
            duration=end-begin,
            message.rate=total.size/as.numeric(duration)/1024/1024) %>%
  ungroup() %>%
  select(begin, end, duration, message.rate)

## # A tibble: 6 x 4
##                 begin                 end       duration message.rate
##                <dttm>              <dttm>         <time>        <dbl>
## 1 2017-07-17 04:27:52 2017-07-17 04:28:13 21.000000 secs    0.4650298
## 2 2017-07-17 04:30:25 2017-07-17 04:32:02  1.616667 secs   30.2029639
## 3 2017-07-17 04:32:58 2017-07-17 04:36:17  3.316667 secs   29.4440955
## 4 2017-07-17 04:18:31 2017-07-17 04:18:54 23.000000 secs    0.4245924
## 5 2017-07-17 04:19:47 2017-07-17 04:21:29  1.700000 secs   28.7224265
## 6 2017-07-17 04:23:10 2017-07-17 04:26:28  3.300000 secs   29.5928030

For details please refer to

@krlmlr
Copy link
Member

krlmlr commented Jul 27, 2017

If you're working with difftime objects, consider using hms which subclasses difftime but always converts to seconds (and prints nicer, too).

@hadley
Copy link
Member

hadley commented Aug 23, 2017

Part of #2432

@hadley hadley closed this as completed Aug 23, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants