library(ggplot2)
scale_fill_msf <- function(...) {
ggplot2:::manual_scale(
"fill",
values = c(
"MSF" = "#D02327",
"OCA" = "#EF5423",
"OCB" = "#FFC70A",
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(sf) | |
library(DBI) | |
library(duckdb) | |
# sf object | |
nc <- st_read(system.file("shape/nc.shp", package = "sf")) | |
nc_crs <- st_crs(nc) | |
# write it to local gpkg | |
path_gpkg <- here::here("local.gpkg") |
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
#' Add custom circle legend to leaflet map | |
#' | |
#' To be used alongside \code{leaflet::addCircleMarkers} | |
#' | |
#' @param map a leaflet map | |
#' @param title title of the legend | |
#' @param range vector of numeric values you want to scale the legend to (same vector used with addCircleMarkers) | |
#' @param scaling_fun the scaling function used with addCircleMarkers to scale circle radii appropriately for leaflet | |
#' @param color stroke color | |
#' @param weight stroke width in pixels |
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) | |
library(magrittr) | |
library(ggplot2) | |
library(officer) | |
ui <- fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100), | |
actionButton("add_plot", "Add to ppt"), |
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) # dev version of ggplot2 required devtools::install_github('hadley/ggplot2') | |
library(sf) | |
extrafont::loadfonts(device = "win") | |
# election results | |
ge_data <- read_csv("http://researchbriefings.files.parliament.uk/documents/CBP-7979/HoC-GE2017-constituency-results.csv") %>% | |
filter(region_name == "London") %>% | |
select(ons_id, constituency_name, con:green) |
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(rvest) | |
library(tidyverse) | |
library(tidygraph) | |
library(ggraph) | |
wc_squads <- read_html("https://en.wikipedia.org/wiki/2018_FIFA_World_Cup_squads") %>% | |
html_table() | |
teams <- c("Egypt", "Russia", "Saudi Arabia", "Uruguay", | |
"Iran", "Morocco", "Portugal", "Spain", |
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
tab2_init <- TRUE | |
observeEvent(input$tabs, { # input$tabs is the menu input | |
if (all(input$tabs == "tab2", tab2_init)) { | |
# change to false so it won't run again | |
tab2_init <<- FALSE | |
# call server module | |
tab2Server("id", ...) | |
} | |
}) |
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") |
NewerOlder