Loading required Libraries

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(leaflet)

Getting and reading the Data set

The data set is obtained from Kaggle. Check it our here https://www.kaggle.com/grebublin/coronavirus-latlon-dataset#

Data <- read.csv("time_series_19-covid-Confirmed.csv")

Pre-processing

Data set contains duplicate values that must be removed. Moreover, I separted data to perform analysis easily.

Data <- distinct(Data, Country.Region, .keep_all = TRUE)
No_of_Patients <- select(Data, -c(Country.Region, Province.State, Lat, Long))
Location_Data <- select(Data, c(Country.Region, Lat, Long))

Data Manipulation

Data set has no of pateints per date. So to get complete number of pateints, sum is calcuated accross all rows.

After calculation, both data frames are binded columnwise so that each row contain Longitude, Latitude and no of patients at that location.

After that, data is arranged according to no of pateints and top 10 locations are fetched

sumData <- rowSums(No_of_Patients)
Covid19_Data <- cbind(Location_Data, sumData)
Covid19_Data <- arrange(Covid19_Data, -sumData)[1:10,]

Drawing Map

my_map <- Covid19_Data %>%
      leaflet() %>%
      addTiles() %>%
      addMarkers(lng = Covid19_Data$Long, lat = Covid19_Data$Lat, popup = Covid19_Data$Country.Region) %>%
      addCircles(weight = 5, radius = Covid19_Data$sumData)
## Assuming "Long" and "Lat" are longitude and latitude, respectively
my_map