1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 15:01:51 +02:00

(v0.9.0.9010) Support R 4.0

This commit is contained in:
2020-01-15 15:24:08 +01:00
parent 64f5ceef03
commit 895e97c310
16 changed files with 43 additions and 26 deletions

View File

@ -26,7 +26,7 @@ library(maps)
library(httr)
GET_df <- function(ip) {
ip <- paste0("https://ipinfo.io/", ip, "?token=089aa7765ee912")
ip <- paste0("https://ipinfo.io/", ip, "?token=", ipinfo_token)
result <- ip %>% GET()
stop_for_status(result)
result %>%
@ -57,6 +57,8 @@ for (i in 2:length(unique_ip)) {
bind_rows(GET_df(unique_ip[i]))
}
ip_tbl.bak <- ip_tbl
# how many?
n_distinct(ip_tbl$country)
@ -90,6 +92,9 @@ countries_geometry <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE)) %>%
not_antarctica = as.integer(ID != "Antarctica"),
countries_name = ifelse(included == 1, ID, NA))
# how many?
countries_geometry %>% filter(included == 1) %>% nrow()
countries_plot <- ggplot(countries_geometry) +
geom_sf(aes(fill = included, colour = not_antarctica),
size = 0.25,
@ -107,7 +112,9 @@ countries_plot_mini$data <- countries_plot_mini$data %>% filter(ID != "Antarctic
countries_plot_mini <- countries_plot_mini + scale_colour_gradient(low = "#81899B", high = "#81899B")
countries_plot_big <- countries_plot +
labs(title = tools::toTitleCase("Countries where the AMR package for R was downloaded from"),
subtitle = paste0("Between March 2018 (first release) and ", format(Sys.Date(), "%B %Y"), ". The dots denote visitors on our website https://gitlab.io/msberends/AMR.")) +
subtitle = paste0("Between March 2018 (first release) and ", format(Sys.Date(), "%B %Y"), "." #,
#"The dots denote visitors on our website https://gitlab.io/msberends/AMR."
)) +
theme(plot.title = element_text(size = 16, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5)) +
geom_text(aes(x = -170,
@ -117,12 +124,12 @@ countries_plot_big <- countries_plot +
paste(countries_name[!is.na(countries_name)], collapse = ", ")),
200)),
hjust = 0,
size = 4) +
# points of visitors
geom_point(data = ip_tbl,
aes(x = x, y = y),
size = 1,
colour = "#81899B")
size = 4) # +
# # points of visitors
# geom_point(data = ip_tbl,
# aes(x = x, y = y),
# size = 1,
# colour = "#81899B")
# main website page
ggsave("pkgdown/logos/countries.png",
@ -143,6 +150,14 @@ ggsave("pkgdown/logos/countries_large.png",
# Gibberish ---------------------------------------------------------------
data %>%
left_join(ip_tbl, by = c("ipaddress" = "ip")) %>%
group_by(country = countrycode::countrycode(country,
origin = 'iso2c',
destination = 'country.name')) %>%
summarise(first = min(timestamp_server)) %>%
arrange(desc(first))
#
# p1 <- data %>%
# group_by(country) %>%