Skip to content

Instantly share code, notes, and snippets.

@PMassicotte
Created October 20, 2020 11:50
Show Gist options
  • Save PMassicotte/dba24992e40fa06dd370151bcfd3ec2c to your computer and use it in GitHub Desktop.
Save PMassicotte/dba24992e40fa06dd370151bcfd3ec2c to your computer and use it in GitHub Desktop.
ctd <- ctd %>%
group_by(station, cast, date_time, longitude, latitude)
ctd
tic()
res <- ctd %>%
mutate(across(
c(flor_mg_m3, sigt_kg_m3),
~ zoo::rollmedian(.x, k = 11, fill = NA, align = "center"),
.names = "{.col}_rollmedian"
))
toc()
tic()
res <- ctd %>%
mutate(across(
c(flor_mg_m3, sigt_kg_m3),
~ RcppRoll::roll_median(.x, n = 11, fill = NA, align = "center"),
.names = "{.col}_rollmedian"
))
toc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment