Skip to content

Instantly share code, notes, and snippets.

@novica
Created May 10, 2018 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save novica/731f581acb5393fc20dd07aaaac8aeeb to your computer and use it in GitHub Desktop.
Save novica/731f581acb5393fc20dd07aaaac8aeeb to your computer and use it in GitHub Desktop.
---
title: "Two-letter MK domain names"
output:
html_document:
df_print: paged
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
# set global chunk options
knitr::opts_chunk$set(echo = FALSE, warning=FALSE, message=FALSE, cache=FALSE)
```
```{r}
suppressPackageStartupMessages(library(tidyverse))
```
```{r}
#get the data
dnames <- read_csv("full_log.csv", col_types = "ccDD", locale = locale(date_format = "%d.%m.%Y"))
```
```{r}
#entries with total count < 5 are grouped as other.
addressSummary <-
dnames %>%
group_by(address) %>%
mutate(count=n()) %>%
arrange(count) %>%
ungroup %>% # key is to ungroup, because otherwise it will try to put grouped addresses (> 1) in the rows with count > 5
mutate(new_address=case_when(
count <= 5 ~ "Other",
count > 5 ~ address))
#split dates
addressSummary <- addressSummary %>%
separate(registeredDate, c("Year", "Month", "Day"), sep = "-", remove = FALSE)
```
```{r}
#Plot domain names by country
ggplot(addressSummary, aes(new_address)) +
geom_bar(aes(x = reorder(new_address, count), fill=new_address), width = 0.5, colour="white") +
scale_fill_brewer(palette = "Paired") +
coord_flip() +
labs(title="Земји од каде лица регистирале 5 или повеќе МК домени \
(во Other се групирани тие со помалку од 5)",
x = "Земји", y = "Број на регистрирани домени", fill = "Земја")
```
```{r}
#Plot domain registration by country over time
addressSummary %>%
group_by(new_address, Year) %>%
mutate(N=n()) %>%
ggplot(aes(x=Year, y=N, group=new_address, colour=new_address)) +
geom_line() +
geom_point() +
scale_color_brewer(palette="Paired")+
labs(title="Регистрирани домени по земја на потекло на регистрант по години \
(во Other се групирани тие со помалку од 5)",
x = "Години", y = "Број на регистрирани домени", color = "Земја") +
theme(axis.text.x = element_text(angle=45, vjust=1, hjust=1))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment