Created
August 2, 2018 03:18
-
-
Save edgararuiz-zz/13ac5067c0e914e1013cc725a89975bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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, warn.conflicts = FALSE) | |
df <- tribble( | |
~id, ~port, | |
"a", "22,33", | |
"a", "22,44", | |
"b", "33, 434" | |
) | |
df %>% | |
transpose() %>% | |
map_df(~tibble( | |
id = .x$id, | |
port = str_split(.x$port, ",")[[1]]) | |
) %>% | |
group_by(id) %>% | |
filter(!duplicated(port)) %>% | |
summarise(port = paste0(port, collapse = ",")) | |
#> # A tibble: 2 x 2 | |
#> id port | |
#> <chr> <chr> | |
#> 1 a 22,33,44 | |
#> 2 b 33, 434 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment