Last active
September 25, 2023 19:19
-
-
Save tanho63/50d9b323e29165ad3e027bc3cf1c5926 to your computer and use it in GitHub Desktop.
pivot_longer sentinel .value - scoobydoo tidy tuesday
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
scooby_data <- read.csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-07-13/scoobydoo.csv") | |
x <- | |
scooby_data %>% | |
select(season, title, | |
starts_with("caught"), | |
starts_with("captured"), | |
starts_with("unmask"), | |
starts_with("snack"), | |
-contains("other"), | |
-contains("not")) %>% | |
filter(title!= "Wrestle Maniacs") | |
three_lines <- x %>% | |
pivot_longer(cols = -c("season","title")) %>% | |
separate(name,into = c("action","character"), sep = "_") %>% | |
pivot_wider(names_from = "action", values_from = "value") | |
one_line <- x %>% | |
pivot_longer(cols = -c("season","title"), names_to = c(".value","character"), names_sep = "_") %>% | |
mutate( | |
across(c("caught","captured","unmask","snack"), ~as.logical(.x) %>% as.integer()) | |
) | |
It just gets better every time you see it
Oh, thank you very much
Iván Villanueva
El 25 sept 2023, a las 21:16, James Cryne ***@***.***> escribió:
@jpcryne commented on this gist.
…________________________________
It just gets better every time you see it
—
Reply to this email directly, view it on GitHub<https://gist.github.com/tanho63/50d9b323e29165ad3e027bc3cf1c5926#gistcomment-4703825> or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANSNFJZH2L2YSDPNAFU7IW3X4HKBHBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTCMBWGU4TSMZRU52HE2LHM5SXFJTDOJSWC5DF>.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some of the best code I've ever seen