|
|
@@ -7,14 +7,31 @@ library(plotly) |
|
|
|
library(forcats) |
|
|
|
library(markdown) |
|
|
|
|
|
|
|
uniq <- function(df, ...) |
|
|
|
uniq <- function(df, ..., first = F) |
|
|
|
{ |
|
|
|
uniq_vector <- function(x, fst) |
|
|
|
{ |
|
|
|
x %>% |
|
|
|
c %>% |
|
|
|
rle %>% |
|
|
|
.$lengths -> |
|
|
|
l |
|
|
|
|
|
|
|
if (fst) |
|
|
|
{ |
|
|
|
l %>% |
|
|
|
cumsum %>% |
|
|
|
`-`(l) + 1 |
|
|
|
} else |
|
|
|
{ |
|
|
|
l %>% cumsum |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
eval(substitute(alist(...))) %>% |
|
|
|
map_chr(as.character) %>% |
|
|
|
intersect(names(df)) %>% |
|
|
|
map(~rle(df[[.x]] %>% c) %>% |
|
|
|
.$lengths %>% |
|
|
|
cumsum) %>% |
|
|
|
map(~uniq_vector(df[[.x]], first)) %>% |
|
|
|
reduce(union) %>% |
|
|
|
sort -> columns |
|
|
|
|
|
|
|