Skip to content

Instantly share code, notes, and snippets.

View BB1464's full-sized avatar

Oluwafemi OYEDELE BB1464

View GitHub Profile
stat_smooth_func <- function(mapping = NULL, data = NULL,
geom = "smooth", position = "identity",
...,
method = "auto",
formula = y ~ x,
se = TRUE,
n = 80,
span = 0.75,
fullrange = FALSE,
level = 0.95,
@fzenoni
fzenoni / ortho_view.R
Last active November 2, 2023 11:06
Preserve polygons in orthographic view
# Download earth data first
# https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_land.zip
library(sf)
library(lwgeom)
library(dplyr)
library(ggplot2)
library(mapview)
# Read the data
@ikashnitsky
ikashnitsky / publons-country.R
Last active November 3, 2023 15:29
Map the country data of Publons (data from https://publons.com/country, manual export on 2021-01-07) – https://twitter.com/ikashnitsky/status/1347325289496502272
#===============================================================================
# 2021-01-07 -- twitter
# Visualize Publons country data
# https://publons.com/country
# Ilya Kashnitsky, [email protected]
#===============================================================================
library(tidyverse)
library(magrittr)
library(sf)
---
title: "Flexdashboard theming demo"
runtime: shiny
output:
flexdashboard::flex_dashboard:
theme:
bg: "#101010"
fg: "#FDF7F7"
primary: "#ED79F9"
base_font: !expr bslib::font_google("Prompt")
@norwegianblueparrot
norwegianblueparrot / bourtange.R
Last active November 25, 2023 03:40
A script to produce a 3D render of Fort Bourtange from LiDAR data
## ----setup,include=FALSE,message=FALSE,warning=FALSE-----------------------------------------------------------------------------------------------------------------------------------------------------
library("here") # 1.0.1
library("sf") # 1.0-14
library("rgl") # 1.2.1
library("geoviz") # 0.2.2
library("raster") # 3.6-26
library("rayshader") # 0.35.7
library("osmdata") # 0.2.5
library("tidyverse") # 2.0.0
@z3tt
z3tt / bars_inside_labels.R
Last active October 29, 2023 04:17
Create colorful bar charts with percentage labels inside each bar
library(tidyverse)
library(systemfonts)
mpg_sum <- mpg %>%
## just use 2008 data
dplyr::filter(year == 2008) %>%
## turn into lumped factors with capitalized names
dplyr::mutate(
manufacturer = stringr::str_to_title(manufacturer),
manufacturer = forcats::fct_lump(manufacturer, n = 10)
@tylermorganwall
tylermorganwall / humanity_globe.R
Created August 17, 2021 14:37
3D Humanity Globe
library(rayshader)
library(rayrender)
popdata = raster::raster("gpw_v4_population_density_rev11_2020_15_min.tif")
population_mat = rayshader:::flipud(raster_to_matrix(popdata))
above1 = population_mat > 1
above5 = population_mat > 5
above10 = population_mat > 10
@kdctran
kdctran / humanity_globe.R
Last active November 23, 2023 21:35 — forked from tylermorganwall/humanity_globe.R
3D Humanity Globe
# data: https://sedac.ciesin.columbia.edu/data/collection/gpw-v4
library(rayshader)
library(rayrender)
popdata = raster::raster("gpw_v4_population_density_rev11_2020_15_min.tif")
population_mat = rayshader:::flipud(raster_to_matrix(popdata))
above1 = population_mat > 1
@tylermorganwall
tylermorganwall / submarine_cable_map.R
Last active August 3, 2025 06:01
Submarine Cable Map Dataviz
library(geojsonsf)
library(sf)
library(rayrender)
#Data source: https://github.com/telegeography/www.submarinecablemap.com
cables = geojson_sf("cable-geo.json")
cablescene = list()
counter = 1
for(i in 1:length(cables$geometry)) {