Skip to content

Instantly share code, notes, and snippets.

@strengejacke
strengejacke / .lintr
Last active April 30, 2024 18:10
VS Code setup for R
// save to windows-user directory
linters: with_defaults(object_name_linter = NULL,
object_length_linter(50),
commented_code_linter = NULL,
object_usage_linter = NULL,
line_length_linter(120),
cyclocomp_linter = cyclocomp_linter(50))

App Install Plan

Critical

@obrl-soil
obrl-soil / tilt_stack_sf.R
Last active December 7, 2023 15:29
Tilted and stacked maps with sf
# further to https://urbandemographics.blogspot.com/2016/04/creating-tilted-and-stacked-maps-in-r.html,
# an sf-friendly approach.
library(sf)
nc <- st_read(system.file('shape/nc.shp', package = 'sf'))
plot(nc)
sm <- matrix(c(2, 1.2, 0, 1), 2, 2)
@leodc
leodc / download_csv.conf
Created November 21, 2019 00:17
NGINX config to download files
server {
listen 80;
server_name default_server;
location ~ ^.*/(?P<request_basename>[^/]+\.(csv))$ {
root /www/data/;
add_header Content-Disposition 'attachment; filename="$request_basename"';
}
}
@aspina7
aspina7 / base_map_example
Last active January 21, 2020 22:17
Base-map plotting offline with {ggspatial}. Current issue is that it will only download tiles if you plot something on top, which makes it not as useful as a standalone. And the res in general. Would also be nice to be able to chuck in coords or a bbox.
## Installing required packages for this template
required_packages <- c("here", # find your files
"dplyr", # clean/shape data
"ggplot2", # create plots and charts
"sf", # encode spatial vector data
"raster", # get and plot GADM shapefiles
"ggspatial") # get and plot base maps
{"lastUpload":"2021-03-11T08:02:06.409Z","extensionVersion":"v3.4.3"}
@uqmessias
uqmessias / countries-names-and-flags-in-portuguese-brazil-pt-br.md
Last active November 10, 2023 17:54
The list of all (or almost all) countries with their names and flag codes in brazilian portuguese (pt-br) and english — Lista de todos (ou quase todos) os países com seus nome e códigos de bandeiras em português brasileiro (pt-br) e inglês.
var countriesInPortugueseBR = [
    {
      flag: 'af',
      nameEn: 'Afghanistan',
      namePt: 'Afeganistão',
    },
    {
      flag: 'za',
library(gganimate) # thomasp85/gganimate
library(cartogram)
library(geogrid) # Need github version jbaileyh/geogrid
library(rnaturalearth)
library(sf)
library(scico)
us <- ne_states('united states of america', returnclass = 'sf')
us <- us[!us$woe_name %in% c('Alaska', 'Hawaii'), ]
us <- st_transform(us, '+proj=eqdc +lat_0=39 +lon_0=-96 +lat_1=33 +lat_2=45 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs')
@timelyportfolio
timelyportfolio / Readme.md
Created March 30, 2018 15:28
shiny datatables update streaming

Let's say you have streaming data, and you would like to update a DT::datatable in Shiny without completely re-rendering the table. Here is some code to illustrate how this might be accomplished. Hope it helps.

library(DT)
library(shiny)

ui <- tagList(
  tags$script(HTML(
"
Shiny.addCustomMessageHandler(