Skip to content

Instantly share code, notes, and snippets.

View Tutuchan's full-sized avatar

Pierre Formont Tutuchan

View GitHub Profile
@bewuethr
bewuethr / partial-rebase.md
Last active April 14, 2025 09:02
Partially rebasing a branch

Rebasing branches partially in Git

Situation

Feature branch feature1 is cut from development:

---o---o---o      <-- development
    \
 A---B---C &lt;-- feature1
@Tutuchan
Tutuchan / diamonds_template.Rmd
Last active December 21, 2019 14:24
Loop over .Rmd chunks
```{r diamonds_{{color}}_{{cut}}_plot}
diamonds %>%
filter(
color == "{{color}}",
cut == "{{cut}}"
) %>%
ggplot(aes(carat, price, colour = clarity)) +
geom_point(show.legend = FALSE) +
labs(
title = 'Price by carat for diamonds with color {{color}} and cut {{cut}}'
@denrou
denrou / shift.R
Last active May 2, 2018 14:47
Add lags to multiple column in a dataframe
shift <- function(x, ..., shifts = 1, suffix = "lag") {
vars <- unname(tidyselect::vars_select(names(x), !!!rlang::quos(...)))
combinations <- expand.grid(var = vars, shift = shifts, stringsAsFactors = FALSE)
shift_cols <- purrr::pmap_dfc(combinations, function(var, shift) {
new_var <- glue::glue("lag_{var}_{shift}")
tibble::tibble(!!new_var := dplyr::lag(x[[var]], shift))
})
dplyr::bind_cols(x, shift_cols)
}