--- title: "Internet Speed Test in R using hrbrmstr/speedtest" author: "Daniel Jachetta III" date: '2018-11-24' slug: internet-speed-test tags: R markdown categories: R markdown ---

Today, we are going to do an internet speed test inside R, with instructions and code from **https://github.com/hrbrmstr/speedtest**. I found this on R bloggers some time ago, and wanted to run this myself.

Below are our packages we used

# devtools::install_github("hrbrmstr/speedtest") 
#packages
library(speedtest)
library(rlang)
library(stringi) 
library(hrbrthemes)
library(ggplot2)
library(ggbeeswarm) 
library(tidyverse)
library(ggmap)
library(rworldmap)
library(rworldxtra)
library(plyr)
library(dplyr)

below is using code from **https://github.com/hrbrmstr/speedtest**. Here we are gathering the best servers to verify our upload,download, and bandwidth speeds. This test is ran through the ookla speedtest site.

#speedtest getting servers
config <- spd_config()
servers <- spd_servers(config=config)
closest_servers <- spd_closest_servers(servers, config=config) 
only_the_best_severs <- spd_best_servers(closest_servers, config)

below is some data wrangling to filter the best servers, and to get the data into a data frame.

bind_rows(
  closest_servers[1:3,] %>%
    mutate(type="closest"),
  only_the_best_severs[1:3,] %>%
    mutate(type="best"),
  filter(servers, !(id %in% c(closest_servers[1:3,]$id, only_the_best_severs[1:3,]$id))) %>%
    sample_n(3) %>%
    mutate(type="random")
) %>%
  group_by(type) %>%
  ungroup() -> to_compare

#column picking
bestselect <- select(to_compare, sponsor, name, country, host, type, lat, lng)
#turning class to data frame
dfbestselect <- as.data.frame(bestselect)

Below is a ggplot2 world map I made using the Latitude and Longitude we got from the speed tests. Each yellow point is where a server was pinged. However I am a bit skeptic as to where some of these servers are in the artic, and in the ocean. Are these server location’s spoofed?