Skip to content

Instantly share code, notes, and snippets.

View pvictor's full-sized avatar

Victor Perrier pvictor

View GitHub Profile
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@wch
wch / app.r
Last active December 18, 2023 16:41
Shiny example app with dynamic number of plots
max_plots <- 5
ui <- fluidPage(
headerPanel("Dynamic number of plots"),
sidebarPanel(
sliderInput("n", "Number of plots", value=1, min=1, max=5)
),
@PaulC91
PaulC91 / addCircleLegend.R
Created March 31, 2020 11:18
Add a custom circle legend to leaflet map in R
#' 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
@dpseidel
dpseidel / default_aes.md
Last active February 12, 2021 17:08
Default ggplot2 aesthetics table

Default ggplot2 aesthetics by geom.

geom alpha angle colour family fill fontface height hjust lineheight linetype shape size stroke vjust weight width xmax xmin ymax ymin
GeomAbline NA black 1 0.5
GeomAnnotationMap NA NA grey20 1 0.5
GeomArea NA NA grey20 1 0.5
GeomBar NA NA grey35 1 0.
library(leaflet)
library(sf)
library(rmapshaper)
library(dplyr, warn.conflicts = FALSE)
library(smoothr)
library(shiny)
u <- httr::GET('https://www.data.gouv.fr/api/1/datasets/5e7e104ace2080d9162b61d8/')
url_search <- httr::content(u)$resources
@yonicd
yonicd / html2tagList.R
Last active April 3, 2020 07:25
convert raw html to htmltools::tagList
#'@title html2tagList
#'@description convert raw html to htmltools tagList
#'@param x character vector of html
#'@examples
#'
#'x<-'<h1>Title</h1>
#' <h2>Header text</h2>
#' <p>Text here</p>
#' <h1>Title</h1>
#' <h2>Header text</h2>
@ikashnitsky
ikashnitsky / colorcoded-map-population-structures.R
Last active February 5, 2020 09:28
Code to reproduce the RGB map of the population structure of NUTS-3 regions of Europe -- https://ikashnitsky.github.io/2017/colorcoded-map/
################################################################################
#
# ikashnitsky.github.io 2017-06-30
# Produce an RGB coded map of pop structures at NUTS-3 level
# Ilya Kashnitsky, ilya.kashnitsky@gmail.com
#
################################################################################
# load required packages
library(tidyverse) # data manipulation and viz
@tomcardoso
tomcardoso / README.md
Last active January 10, 2020 09:22
Reusable waffle charts

Reusable waffle charts

Basic waffle charts using Mike Bostock's [http://bost.ocks.org/mike/chart/](reusable charts) convention. Waffles are configurable, as you can see below:

var waffle = new WaffleChart()
  .selector(".chart")
  .data(data)
  .useWidth(false)
 .label("Value of producers' sales in 2013, in thousands of dollars")
@theHausdorffMetric
theHausdorffMetric / margintale_blog_2.R
Created April 14, 2012 20:33
Time Series Heatmaps in ggplot2
require(quantmod)
require(ggplot2)
require(reshape2)
require(plyr)
require(scales)
# Download some Data, e.g. the CBOE VIX
getSymbols("^VIX",src="yahoo")
# Make a dataframe
@jeroen
jeroen / favicon.R
Last active February 14, 2019 21:32
Generate favicon with magick
library(magick)
library(magrittr)
# Convert to 'ico' format
image_read("https://www.r-project.org/logo/Rlogo.png") %>%
image_scale("32x32!") %>% # remove the "!" after 32x32 to scale proportionally
image_write("favicon.ico", format = "ico")
# Favicon can also be png/gif