Skip to content

Instantly share code, notes, and snippets.

View jlacko's full-sized avatar
🦜
wrrritin' pirrrate code, arrr!

Jindra Lacko jlacko

🦜
wrrritin' pirrrate code, arrr!
View GitHub Profile
library(dplyr)
library(ggplot2)
library(statnipokladna)
local_budgets <- sp_get_table(table_id = "budget-local", # table ID, see `sp_tables`
year = 2020,
month = 12,
dest_dir = "data/budget_data")
functional_categories <- sp_get_codelist("paragraf",
dest_dir = "data/budget_data")
@DavZim
DavZim / map_projections.R
Created January 20, 2021 10:37
Creates a gif of the world in different map projections
library(tidyverse)
library(sf)
library(spData)
library(gganimate)
data(world)
# see also: https://proj.org/operations/projections/index.html
projs <- list(
"Mercator" = "+proj=merc",
<!DOCTYPE qgis_style>
<qgis_style version="2">
<symbols>
<symbol alpha="1" force_rhr="0" clip_to_extent="1" type="fill" name="pencilish">
<layer class="MarkerLine" pass="0" locked="0" enabled="1">
<prop k="average_angle_length" v="4"/>
<prop k="average_angle_map_unit_scale" v="3x:0,0,0,0,0,0"/>
<prop k="average_angle_unit" v="MM"/>
<prop k="interval" v="0.02"/>
<prop k="interval_map_unit_scale" v="3x:0,0,0,0,0,0"/>
@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
@nuest
nuest / sf-hexagon-with-sf.R
Created January 11, 2018 14:17
sf hexagon sticker with sf
library("sf")
library("dplyr")
library("hexbin")
# Linux libertine fint "sf", converted to path with Inkscape,
# added points between existing points 2 times, then turned all segments into straight lines.
# Saved as SVG with absolute coordinates (Preferences > SVG Output > Path Data).
# Loaded coords from SVG source code, remove letters from start and end, and replace " " with ","
coords_f <- c(218.1169,163.46992,215.56952,177.96334,213.51976,189.84421,211.82546,200.33884,210.34442,210.67351,208.24728,226.35176,205.51032,243.54066,201.92029,259.27223,197.26391,270.57846,195.45112,272.90665,193.28288,274.70167,190.97247,275.85687,188.73314,276.26564,187.03291,276.03164,185.79476,275.38887,184.84097,274.42619,183.99382,273.23248,182.45947,271.13533,180.24976,269.10927,177.54243,267.58084,174.51519,266.97658,171.25987,267.58973,169.08867,269.18036,167.87718,271.37526,167.501,273.8012,168.44294,277.0032,171.48203,279.79643,176.93817,281.77214,185.13126,282.52154,191.01986,281.80176,196.83737,279.60686,202.29944,
@raadk
raadk / excelFinance.R
Last active September 11, 2023 10:01
Excel's PMT, IPMT, PPMT implemented in R
#' Excel: PMT (should make result data frame, but need to change propertyAnalysis())
#'
#' Returns the payment amount for a loan based on a constant interest rate and a constant payment schedule.
#' The payment returned by PMT includes principal and interest but no taxes,
#' reserve payments, or fees sometimes associated with loans.
#' Outgoing payments are displayed by negative numbers and
#' incoming payments by positive numbers.
#' #http://support2.microsoft.com/kb/214005#appliesto
#' @param rate Required. The interest rate per period. Needs to be defined as the same periods as nper.
#' @param per Required. The period for which you want to find the interest and must be in the range 1 to nper.