Тёмный

Beyond Basic For loops: Tidy Expressions | TidyX Episode 170 

TidyX
Подписаться 3,8 тыс.
Просмотров 565
50% 1

TidyX Episode 170: Beyond Basic For loops - Tidy Expressions
We jump into the intricacies of for loops, pushing beyond the basics into the realm of Tidy Expressions, using the power of efficient coding using tidyverse functions, double curly embraces, and str2lang. By doing this, we can leverage tidyverse functions for efficient coding in custom functions and maintain the non standard evaluation tricks used by tidyverse!
Like, Subscribe, and find us on social media! (@ellis_hughes, @OSPpatrick, @tidy_explained).
If you like what we are doing, please sign up to be a patron on Patreon!
/ tidy_explained
Email us with any comments, questions, or suggestions at tidy.explained@gmail.com.
Links:
Open an issue on the TidyX Github page!
github.com/thebioengineer/Tid...
Patreon:
/ tidy_explained
TidyX Code:
github.com/thebioengineer/Tid...

Опубликовано:

 

20 янв 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 6   
@ArcenisRojas
@ArcenisRojas 5 месяцев назад
Also, thank you both for this video!
@rayflyers
@rayflyers 5 месяцев назад
You can accomplish it with a single pivot longer if the column names have a consistent pattern/separator. I gave the stat variables a new suffix ("_score") to make that happen. fake_dat |> rename_with(\(x) str_replace(x, "(.+\\d$)", "\\1_score")) |> pivot_longer( c(ends_with("_score"), ends_with("_n")), names_to = c("stat", ".value"), names_sep = "_", ) |> summarize( total_obs = sum(n), wgt_stat = weighted.mean(score, n), .by = c(athlete, stat) )
@zl1061
@zl1061 5 месяцев назад
Really appreciate the for loop solution as often running into this situation myself and I always wondered if you can do this without running the same code multiple times. This has been super helpful!
@Matt_Kumar
@Matt_Kumar 5 месяцев назад
Keeping Patrick on his toes :)
@ArcenisRojas
@ArcenisRojas 5 месяцев назад
If you must use a for loop... # Using a for loop library(rlang) wgt_stat_list
Далее