Skip to content

Instantly share code, notes, and snippets.

View z3tt's full-sized avatar
👨‍💻
Coding at home

Cédric Scherer z3tt

👨‍💻
Coding at home
View GitHub Profile
@z3tt
z3tt / data.R
Last active August 28, 2018 19:38
Raincloudplots - movement model versus number of infection
dat <- structure(list(Move = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
@z3tt
z3tt / cedrics_theme.R
Created May 22, 2019 18:02
My ggplot theme
##----------------------------------------------------------------------------------------------------------##
## Cedric Scherer (cedricphilippscherer@gmail.com) ##
## Function for a custom ggplot theme ##
## 2017-05-27 ##
##----------------------------------------------------------------------------------------------------------##
library(ggplot2)
if ("extrafont" %in% rownames(installed.packages()))
{
## from Hugo Toscano: https://github.com/toscano84/TidyTuesday/blob/master/Week23/TT_week23_fastfood.R
"%||%" <- function(a, b) {
if (!is.null(a))
a
else
b
}
geom_flat_violin <-
``` r
library(tidyverse)
library(raster)
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
oceans <-
rnaturalearth::ne_download(scale = 10,
category = "physical",
type = "ocean",
library(tidyverse)
library(lubridate)
locations <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-06-23/locations.csv')
movement <- locations %>%
filter(study_site != "Hart Ranges") %>%
mutate(
season = fct_rev(season), # reverse seasons
longitude = round(longitude, 2), # round long, lat to reduce number of points
@z3tt
z3tt / geom_point_transparency.R
Last active July 29, 2020 11:49
Test transparency geom_point()
library(tidyverse)
library(patchwork)
df <- tibble(x = 1, y = 1)
g <- ggplot(df, aes(x, y)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
@z3tt
z3tt / tmap-shiny
Created August 27, 2020 18:35
tmap in shiny
library(shiny)
library(tmap)
data(World)
world_vars <- setdiff(names(World), c("iso_a3", "name", "sovereignt", "geometry"))
ui <- fluidPage(
tmapOutput("map"),
selectInput("var", "Variable", world_vars)
@z3tt
z3tt / tmap_fullPage
Created August 28, 2020 13:10
tmap fullPage
library(shiny)
library(tmap)
library(tidyverse)
library(fullPage)
data(World)
world_vars <- setdiff(names(World), c("iso_a3", "name", "sovereignt", "geometry"))
ui <- pagePiling(
sections.color = c('#ebebeb', '#f1f1f1'),
@z3tt
z3tt / tt_2020_52.R
Last active December 27, 2020 19:16
gganimate problem
library(tidyverse)
library(gganimate)
library(systemfonts)
df_mac_raw <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-12-22/big-mac.csv')
df_mac <-
df_mac_raw %>%
mutate(year = lubridate::year(date)) %>%
dplyr::select(date, year, iso_a3, currency_code, name, local_price,
@z3tt
z3tt / arc.R
Last active March 18, 2021 18:38
arc graph example for sorting
library(tidyverse)
library(igraph)
library(ggraph)
df <- readRDS("data.Rds")
graph <- graph_from_data_frame(df)
sorting <- c(25, 24, 1, 2, 3, 4, 5, 6, 7, 8, 26, 27, c(9:23))