Skip to content

Instantly share code, notes, and snippets.

Avatar

Victor Perrier pvictor

View GitHub Profile
View covidfrance_shiny.R
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
@gaborcsardi
gaborcsardi / Pkgdown deploy from Travis.md
Last active Jun 8, 2020
Walkthrough: deploy a pkgdown site from Travis
View Pkgdown deploy from Travis.md

Run usethis::use_pkgdown_travis()

usethis::use_pkgdown_travis()
✔ Setting active project to '/Users/gaborcsardi/works/ps'Adding 'docs/' to '.gitignore'Set up deploy keys by running `travis::use_travis_deploy()`Insert the following code in '.travis.yml'
  before_cache: Rscript -e 'remotes::install_cran("pkgdown")'
@cderv
cderv / knitr_child_ex1.Rmd
Last active Jan 27, 2019
Examples for Rmarkdown cookbook
View knitr_child_ex1.Rmd
---
title: "Programmatically create a document"
date: "`r Sys.Date()`"
output:
pagedown::html_paged:
toc: true
# change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
self_contained: false
---
@ikashnitsky
ikashnitsky / colorcoded-map-population-structures.R
Last active Feb 5, 2020
Code to reproduce the RGB map of the population structure of NUTS-3 regions of Europe -- https://ikashnitsky.github.io/2017/colorcoded-map/
View colorcoded-map-population-structures.R
################################################################################
#
# 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
@yonicd
yonicd / html2tagList.R
Last active Apr 3, 2020
convert raw html to htmltools::tagList
View html2tagList.R
#'@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>
@jeroen
jeroen / favicon.R
Last active Feb 14, 2019
Generate favicon with magick
View favicon.R
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
@slowkow
slowkow / plot_repel.R
Last active May 2, 2018
Repel text labels away from each other in a ggplot2 figure.
View plot_repel.R
library(ggplot2)
library(FField)
# You'll have to play with repulsion, cex.x, and cex.y to get satisfactory results.
plot_text <- function(x, y, label, repulsion = 1, cex.x = 110, cex.y = 40) {
dat <- data.frame(xpos = x, ypos = y, label = label)
dat$label <- as.character(dat$label)
# Use the FField package to repel the text labels away from each other.
dat <- cbind(
@tomcardoso
tomcardoso / README.md
Last active Jan 10, 2020
Reusable waffle charts
View README.md

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")
@wch
wch / server.r
Last active Sep 1, 2020
Shiny example app with dynamic number of plots
View server.r
max_plots <- 5
shinyServer(function(input, output) {
# Insert the right number of plot output objects into the web page
output$plots <- renderUI({
plot_output_list <- lapply(1:input$n, function(i) {
plotname <- paste("plot", i, sep="")
plotOutput(plotname, height = 280, width = 250)
})
@theHausdorffMetric
theHausdorffMetric / margintale_blog_2.R
Created Apr 14, 2012
Time Series Heatmaps in ggplot2
View margintale_blog_2.R
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
You can’t perform that action at this time.