Skip to content

Commit

Permalink
1. Сделал подгрузку из ранее подготовленного файла.
Browse files Browse the repository at this point in the history
2. Посчитал "денежки"
  • Loading branch information
iMissile committed May 24, 2017
1 parent fd5f49f commit 2864af0
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions 72 bee_cdp/process_bee_cdr.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ fields <-
)
)

# ëèáî ïàðñèì èñõîäíûå ôàéëû, ëèáî ïîäãðóæàåì óæå ðàíåå êîíñîëèäèðîâàííûé
if (FALSE){
cdr_spec <- tibble(fields) %>%
separate(fields, into=c("cname", "ctype"), sep=":") %>%
replace_na(list(ctype = "c"))
Expand Down Expand Up @@ -89,6 +91,17 @@ df <- df0 %>%

toc()

tic()
write_csv(df, "CDP_result.log.gz")
saveRDS(df, file="CDP_result.rds")
toc()
} else{
tic()
df <- readRDS("CDP_result.rds")
toc()
}


tic()
# ïîñ÷èòàåì êîëè÷åñòâî óíèêàëüíûõ çíà÷åíèé â êîëîíêàõ
dist_cols <- map_df(df, n_distinct)
Expand All @@ -103,9 +116,6 @@ a_df <- df %>%
summarise(n=n()) %>%
arrange(desc(n))

tic()
write_csv(df, "CDP_result.log.gz")
toc()

# ïîïðîáóåì îòîáðàçèòü ãðàôèêè. ïðåäâàðèòåëüíàÿ ïîäãîòîâêà ================
df %<>%
Expand Down Expand Up @@ -191,6 +201,24 @@ gg = gg + facet_wrap(~message_type, ncol=1)

gg

# Ïîèññëåäóåì äåíåæêè ====================================
df3 <- df %>%
filter(!is.na(sdr_amount) & sdr_amount>0) %>%
group_by(CP) %>%
summarize(rur=sum(sdr_amount)/100000)


gg <- ggplot(df3 %>% top_n(10, rur), aes(x=fct_reorder(CP, rur, .desc=TRUE), y=rur)) +
geom_bar(stat="identity") +
theme_ipsum_rc(base_size=14, axis_title_size=12) +
theme(axis.text.x = element_text(angle=90)) +
geom_text(aes(label=rur), vjust=-0.5, colour="red") +
xlab("Êîíòåíò-ïðîâàéäåð") +
ylab("Äåíåæêè çà ïåðèîä àíàëèçà, ðóá.") +
ggtitle("Àíàëèç äåíåæíûõ ïîòîêîâ")

gg

if (FALSE){
# ïðîâåðèì êàêîé èç âàðèàíòîâ ïî îòáðîñó ïîëíîñòüþ NA êîëîíîê áûñòðåå
f1 <- function(df) {
Expand Down

0 comments on commit 2864af0

Please sign in to comment.