Skip to content

Commit

Permalink
Generally avoid add/.add argument of dplyr
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed May 26, 2020
1 parent 7f1c1c9 commit d86127b
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions R/collapse_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#' # calculate monthly standard deviation for each column
#' FANG %>%
#' dplyr::mutate(date = collapse_index(date, "monthly")) %>%
#' dplyr::group_by(date, add = TRUE) %>%
#' dplyr::group_by(symbol, date) %>%
#' dplyr::summarise_all(sd)
#'
#'
Expand Down Expand Up @@ -178,7 +178,7 @@ collapse_index <- function(index, period = "yearly",
#' # calculate monthly standard deviation for each column
#' FANG %>%
#' collapse_by("monthly") %>%
#' dplyr::group_by(date, add = TRUE) %>%
#' dplyr::group_by(symbol, date) %>%
#' dplyr::summarise_all(sd)
#'
#' @export
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ FANG %>%
collapse_by("year") %>%
# Additionally group by date (yearly)
group_by(date, add = TRUE) %>%
group_by(symbol, date) %>%
# Perform a yearly summary for each symbol
summarise(
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,14 @@ FANG %>%
collapse_by("year") %>%

# Additionally group by date (yearly)
group_by(date, add = TRUE) %>%
group_by(symbol, date) %>%

# Perform a yearly summary for each symbol
summarise(
adj_min = min(adjusted),
adj_max = max(adjusted),
adj_range = adj_max - adj_min
)
#> Warning: The `add` argument of `group_by()` is deprecated as of dplyr 1.0.0.
#> Please use the `.add` argument instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> `summarise()` regrouping output by 'symbol' (override with `.groups` argument)
#> # A time tibble: 16 x 5
#> # Index: date
Expand Down
2 changes: 1 addition & 1 deletion man/collapse_by.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/collapse_index.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/TT-04-use-with-dplyr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ price_series <- bind_rows(list(apple = apple, facebook = facebook), .id = "symbo
# common financial transformation
price_series %>%
collapse_by("daily") %>%
group_by(date, add = TRUE) %>%
group_by(symbol, date) %>%
summarise(
open = first(price),
high = max(price),
Expand Down

0 comments on commit d86127b

Please sign in to comment.