Why use the magrittr pipe and cool tricks in R 4.1

Поделиться
HTML-код
  • Опубликовано: 9 ноя 2024

Комментарии • 10

  • @Sefran12
    @Sefran12 3 года назад +2

    nice. It is extremely rare seeing someone use R without Rstudio. Cheers and good video

  • @johnsnyder7795
    @johnsnyder7795 3 года назад

    Would LOVE a video walking through your development environment!
    The anonymous function shorthand introduced in 4.1 alongside |> solves the issue of missing the 'dot' functionality that %>% has. Your second example works as follows:
    mtcars |>
    dplyr::mutate(mpg2 = 2*mpg) |>
    { \(x)
    if(filter_check) {
    dplyr::filter(x, mpg == 21)
    } else{
    dplyr::filter(x, mpg != 21)
    }
    }() |>
    dplyr::select(mpg,mpg2)

    • @AndyQuinteroM
      @AndyQuinteroM  3 года назад

      Cool thanks for the tip. The syntax looks kind of weird but I guess it gets the job done.
      I’m thinking about starting a series writing an app from scratch, that would be a good moment to show my development environment

    • @SomeElderMilennial
      @SomeElderMilennial 3 года назад

      @@AndyQuinteroM awesome I'm looking forward. This is great stuff, looking forward to seeing you grow.

  • @haraldurkarlsson1147
    @haraldurkarlsson1147 Год назад +1

    Interesting since the base pipe seems to replacing the magrittr pipe in all the presentations I have seen in the last six months or so. Therefore the issues the base pipe had/has are resolved?

    • @pipertripp
      @pipertripp 8 месяцев назад +1

      you can use the _ in place of the . when using the base R pipe.

  • @haraldurkarlsson1147
    @haraldurkarlsson1147 Год назад

    Yeah. I am a Vim user put is it hard not to use RStudio. It is simply embedded in my soul by now.

  • @richardbennett4365
    @richardbennett4365 Год назад

    He keeps saying empty cars.
    Anyway, he's not comparing apples to apples. He says base r pipe |> doesn't work in his example and then goes on to show %>% does work, but he added , df = . in the expression with %>% but did not in the expression with |>. How's that a proper comparison???
    I cannot understand that kind of illogical teaching.