This is an R HTML document. When you click the Knit HTML button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(ggmap)
## Loading required package: ggplot2
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
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(ggplot2)
library(leaflet)
data(quakes)
summary(quakes)
##       lat              long           depth            mag      
##  Min.   :-38.59   Min.   :165.7   Min.   : 40.0   Min.   :4.00  
##  1st Qu.:-23.47   1st Qu.:179.6   1st Qu.: 99.0   1st Qu.:4.30  
##  Median :-20.30   Median :181.4   Median :247.0   Median :4.60  
##  Mean   :-20.64   Mean   :179.5   Mean   :311.4   Mean   :4.62  
##  3rd Qu.:-17.64   3rd Qu.:183.2   3rd Qu.:543.0   3rd Qu.:4.90  
##  Max.   :-10.72   Max.   :188.1   Max.   :680.0   Max.   :6.40  
##     stations     
##  Min.   : 10.00  
##  1st Qu.: 18.00  
##  Median : 27.00  
##  Mean   : 33.42  
##  3rd Qu.: 42.00  
##  Max.   :132.00

You can also embed plots, for example:

quakes1 <- quakes %>% filter(mag>5.5)
leaflet(data = quakes1) %>% addTiles() %>%
  addMarkers(~long, ~lat, popup = ~as.character(mag))
plot of chunk unnamed-chunk-2
 pal <- colorFactor(palette = c("green","yellow","red" ),domain = quakes1$mag)


  leaflet(data = quakes1) %>% addTiles() %>%
  addCircleMarkers(~long, ~lat, popup=~as.character(mag), radius=3,fillOpacity = 0.8,color=pal(quakes1$mag))%>%
  addLayersControl(overlayGroups = c("circles")) %>%
  #addLegend(pal = pal, values = ~mag, group = "circles", position = "bottomleft")#%>%
  addLegend(position = 'bottomright',pal=pal, values = ~mag)
plot of chunk unnamed-chunk-2