library(leaflet)
## Warning: package 'leaflet' was built under R version 3.4.4
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.4
##
## 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
universities <- data.frame(name = c("Kansas State", "Kansas", "Iowa State","Texas Tech","Baylor","Texas","TCU","Oklahoma","Oklahoma State","West Virginia"), lat = c(39.1974,38.9543,42.0266,33.5843,31.5497,30.2849,32.7096,35.2059,35.2059,39.6361), lng = c(-96.5847,-95.2558,-93.6465,-101.8783,-97.1143,-97.7341,-97.3636,-97.4457,-97.0737,-79.9559), website = c("<a href='https://www.k-state.edu/'>Read About Kansas State</a>","<a href='https://ku.edu/'>Read About Kansas</a>","<a href='https://www.iastate.edu/'>Read About Iowa State</a>","<a href='https://www.ttu.edu/'>Read About Texas Tech</a>","<a href='https://www.baylor.edu/'>Read About Baylor</a>","<a href='https://www.utexas.edu/'>Read About Texas</a>","<a href='http://www.tcu.edu/'>Read About TCU</a>","<a href='https://www.ou.edu/'>Read About Oklahoma</a>","<a href='https://go.okstate.edu/'>Read About Oklahoma State</a>","<a href='https://www.wvu.edu/'>Read About West Virginia</a>"))
KansasStateIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/6/6f/Kansas_State_Wildcats_baseball_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
KansasIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/1/1a/Kansas_Jayhawks_wordmark.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
IowaStateIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/f/f9/Iowa_State_Cyclones_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
TexasTechIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/4/4e/Texas_Tech_Athletics_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
BaylorIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/c/c4/Baylor_Athletics_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
TexasIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/c/c0/UT%26T_text_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
TCUIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/1/15/TCU_Horned_Frogs_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
OklahomaIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/6/61/Oklahoma_Sooners_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
OklahomaStateIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/d/d6/Oklahoma_State_University_Athletics_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
WestVirginiaIcon <- makeIcon(
iconUrl = "https://upload.wikimedia.org/wikipedia/commons/e/e8/West_Virginia_Mountaineers_logo.svg",
iconWidth = 60*215/230,
iconHeight = 50,
iconAnchorX = 31*215/230/2,
iconAnchorY = 16)
IconSet <- iconList(KansasStateIcon,KansasIcon,IowaStateIcon,TexasTechIcon,BaylorIcon,TexasIcon,TCUIcon,OklahomaIcon,OklahomaStateIcon,WestVirginiaIcon)
universities %>%
leaflet() %>%
addTiles()%>%
addMarkers(icon =IconSet, popup = universities$website)%>%
setView(lng =-92.5847, lat = 35.1974, zoom = 4.2)
## Assuming "lng" and "lat" are longitude and latitude, respectively
head(universities)
## name lat lng
## 1 Kansas State 39.1974 -96.5847
## 2 Kansas 38.9543 -95.2558
## 3 Iowa State 42.0266 -93.6465
## 4 Texas Tech 33.5843 -101.8783
## 5 Baylor 31.5497 -97.1143
## 6 Texas 30.2849 -97.7341
## website
## 1 <a href='https://www.k-state.edu/'>Read About Kansas State</a>
## 2 <a href='https://ku.edu/'>Read About Kansas</a>
## 3 <a href='https://www.iastate.edu/'>Read About Iowa State</a>
## 4 <a href='https://www.ttu.edu/'>Read About Texas Tech</a>
## 5 <a href='https://www.baylor.edu/'>Read About Baylor</a>
## 6 <a href='https://www.utexas.edu/'>Read About Texas</a>