This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addBubbleLegend <- function( | |
map, title = "", range, scaling_fun, ..., | |
strokeColor, weight, fillColor, fillOpacity, | |
position = c("topright", "bottomright", "bottomleft", "topleft"), | |
data = getMapData(map), layerId = NULL | |
) { | |
range <- base::pretty(sort(range), 20) | |
range <- range[range != 0] | |
min_n <- min(range, na.rm = TRUE) | |
med_n <- median(range, na.rm = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remotes::install_github("paulc91/waffle", ref = "1.0.0") | |
library(tidyverse) | |
library(waffle) | |
storms %>% | |
filter(year >= 2010) %>% | |
count(year, status) -> storm_df | |
ggplot(storm_df, aes(fill=status, values=n)) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ================================================================================= | |
# lightweight packrat setup as outlined here: https://milesmcbain.xyz/packrat-lite/ | |
# ================================================================================= | |
# initiliase a packrat project in your project directory | |
packrat::init( | |
infer.dependencies = FALSE, | |
options = list(vcs.ignore.lib = TRUE, vcs.ignore.src = TRUE) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(highcharter) | |
library(tibble) | |
df <- tibble( | |
group = c(rep("G1", 3), rep("G2", 4)), | |
cat = c("B", "C", "D", "A", "B", "C", "D"), | |
index = c(2, 3, 4, 1, 2, 3, 4), | |
n = runif(7) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(shinyauthr) | |
library(shinyjs) | |
user_base <- data.frame( | |
user = c("user1", "user2"), | |
password = c("pass1", "pass2"), | |
permissions = c("admin", "standard"), | |
name = c("User One", "User Two"), | |
stringsAsFactors = FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
ui <- fluidPage( | |
tags$head(includeScript("returnClick.js")), | |
textInput("myText", "", placeholder = "Enter text then hit return", width = "100%"), | |
actionButton("myButton", "Go!"), | |
verbatimTextOutput("textOutput") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(shinyjs) | |
library(leaflet) | |
ui <- bootstrapPage( | |
tags$head(includeCSS("styles.css")), | |
shinyjs::useShinyjs(), | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(rvest) | |
library(opencage) # need to get opencage API key and save as env variable below https://geocoder.opencagedata.com/pricing | |
library(sf) | |
library(rnaturalearth) | |
library(gganimate) # devtools::install_github('thomasp85/gganimate') | |
library(hrbrthemes) # devtools::install_github('hrbrmstr/hrbrthemes') | |
Sys.setenv(OPENCAGE_KEY = "xxxxxxxxxxxxxxxx") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Data available here | |
# https://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/birthsdeathsandmarriages/livebirths/adhocs/009010babynames1996to2017englandandwales/adhocallbabynames1996to2017.xls | |
library(tidyverse) | |
library(readxl) | |
rank_names <- map_chr(2017:1996, paste0, "-rank") | |
count_names <- map_chr(2017:1996, paste0, "-count") | |
cnames <- c(rank_names, count_names) %>% sort(decreasing = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gapminder) | |
library(openxlsx) | |
gm <- gapminder %>% | |
select(-continent) | |
# to get latest year as first tab in workbook | |
years <- unique(gm$year) %>% sort(decreasing = TRUE) |