library(ggplot2) # makes pretty figures
library(dplyr) # manipulate data
library(tidyr) # manipulate data
library(leaflet) # mapping package
dat<-read.csv("FACT_Activism_activity_log.csv",skip=1)
glimpse(dat)
## Observations: 33
## Variables: 22
## $ N <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, …
## $ Full_date <fct> 3/24/18, 4/28/18, 7/14/18, 8/1/18, 8/12/18, 9/1…
## $ Year <int> 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018,…
## $ Month <int> 3, 4, 7, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10…
## $ Day <int> 24, 28, 14, 1, 12, 1, 8, 6, 26, 28, 29, 5, 13, …
## $ Time.Start <fct> 16:00, 18:00, 18:30, 18:00, 19:00, 17:00, 18:30…
## $ Time.End <fct> 18:00, 20:00, 21:30, 21:00, 21:00, 19:00, 21:30…
## $ Total.Time <dbl> 2.0, 2.0, 3.0, 3.0, 2.0, 2.0, 3.0, 2.0, 3.0, 1.…
## $ Lat <dbl> 30.31882, 30.31390, 25.79069, 30.44209, 30.3041…
## $ Lon <dbl> -81.66060, -81.68108, -80.13215, -84.29460, -81…
## $ Location <fct> "1025 Museum Cir", "1059 park st", "1650 Washin…
## $ City <fct> Jacksonville, Jacksonville, Miami, Tallahassee,…
## $ State <fct> Florida, Florida, Florida, Florida, Florida, Fl…
## $ Total.Tally <int> NA, NA, 220, 14, 14, 20, 158, 29, 23, 26, 48, 3…
## $ Andrew.Tally <int> 2, 8, 9, 12, 1, 1, 6, 8, 12, 10, 8, 8, 5, 13, 1…
## $ Cady.Tally <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, NA, NA, NA, NA, …
## $ Andrew.Cube.Time <dbl> 1.00, 1.00, 1.00, 1.00, 0.50, 0.00, 0.25, 0.50,…
## $ Cady.Cube.Time <dbl> 3.0, 2.5, 3.0, 3.0, 1.0, 0.5, 2.0, 1.5, 0.0, NA…
## $ Milena.Tally <int> NA, NA, NA, NA, NA, 0, NA, NA, 2, 6, NA, 1, NA,…
## $ Milena.Cube.Time <dbl> NA, NA, NA, NA, NA, 2.5, NA, NA, 0.0, 0.0, NA, …
## $ Sam.Tally <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Sam.Cube.Time <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
dat$FACT_tally<-dat[,-14]%>%
select(contains("Tally"))%>%
apply(.,1,sum,na.rm=TRUE)
dat$Total.Tally<-dat$Total.Tally-dat$FACT_tally
# mess with data set
# group by city and then calculate total tally, take average lat and lon too
dat.map<-dat%>%
group_by(City)%>%
summarise(lat=mean(Lat),lon=mean(Lon),tally.size=sum(Total.Tally,na.rm=TRUE)/5+1,fact=sum(FACT_tally,na.rm=TRUE)/3+1)
## making the map
m <- leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
setView(lng = -81.991014, lat = 28.669030, zoom = 7)%>%
addCircleMarkers(lng=dat.map$lon, lat=dat.map$lat,radius=dat.map$tally.size,color="black")
m # Print the map
sessionInfo()
## R version 3.5.1 (2018-07-02)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS 10.14.2
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] bindrcpp_0.2.2 leaflet_2.0.2 tidyr_0.8.2 dplyr_0.7.8
## [5] ggplot2_3.1.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.0 later_0.7.5 pillar_1.3.1 compiler_3.5.1
## [5] plyr_1.8.4 bindr_0.1.1 tools_3.5.1 digest_0.6.18
## [9] jsonlite_1.6 evaluate_0.12 tibble_2.0.1 gtable_0.2.0
## [13] pkgconfig_2.0.2 rlang_0.3.1 cli_1.0.1 shiny_1.2.0
## [17] crosstalk_1.0.0 yaml_2.2.0 xfun_0.4 withr_2.1.2
## [21] stringr_1.3.1 knitr_1.21 htmlwidgets_1.3 grid_3.5.1
## [25] tidyselect_0.2.5 glue_1.3.0 R6_2.3.0 fansi_0.4.0
## [29] rmarkdown_1.11 purrr_0.2.5 magrittr_1.5 promises_1.0.1
## [33] scales_1.0.0 htmltools_0.3.6 assertthat_0.2.0 xtable_1.8-3
## [37] mime_0.6 colorspace_1.4-0 httpuv_1.4.5.1 utf8_1.1.4
## [41] stringi_1.2.4 lazyeval_0.2.1 munsell_0.5.0 crayon_1.3.4