Skip to content

Instantly share code, notes, and snippets.

@tanho63
tanho63 / scoobydoo_pivot.R
Last active September 25, 2023 19:19
pivot_longer sentinel .value - scoobydoo tidy tuesday
library(tidyverse)
scooby_data <- read.csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-07-13/scoobydoo.csv")
x <-
scooby_data %>%
select(season, title,
starts_with("caught"),
starts_with("captured"),
starts_with("unmask"),
@tanho63
tanho63 / graph_upload.R
Last active January 29, 2021 20:49
Upload file to Microsoft Graph/Sharepoint API
# I struggled with uploading things to Microsoft Graph API/Sharepoint/OneDrive for business - here's the code that finally worked for me.
library(AzureGraph)
library(httr)
# Creates authentication token via browser
graph_token <- AzureGraph::create_graph_login()$token
# Send a PUT request to the Microsoft Graph API
@chichacha
chichacha / packingcircle_deldir.r
Created December 23, 2018 07:35
Circle Packing + Delaunay Triangulation
library(tidyverse)
library(deldir)
library(packcircles)
packing <- circleProgressiveLayout(x=runif(1000)) %>% mutate(id=row_number())
data_gg <- circleLayoutVertices(packing, npoints = 36) %>%
inner_join(packing %>% select(id,radius), by=c("id"))
dxy1 <- deldir(packing$x, packing$y)
@mattmc3
mattmc3 / modern_sql_style_guide.md
Last active April 27, 2024 00:11
Modern SQL Style Guide
layout author title revision version description
default
mattmc3
Modern SQL Style Guide
2019-01-17
1.0.1
A guide to writing clean, clear, and consistent SQL.

Modern SQL Style Guide

@amrrs
amrrs / app.r
Created November 21, 2017 08:04
How to upload and embed pdf in R shiny (iframe)
library(shiny)
ui <- shinyUI(fluidPage(
titlePanel("Testing File upload"),
sidebarLayout(
sidebarPanel(
fileInput('file_input', 'upload file ( . pdf format only)', accept = c('.pdf'))
),
@alexhanna
alexhanna / social-science-programming.md
Last active March 14, 2024 11:05
Notes on social science programming principles
  1. Code and Data for the Social Sciences: A Practitioner’s Guide, Gentzkow and Shapiro.
  2. Good enough practices in scientific computing, Wilson et al.
  3. Best Practices for Scientific Computing, Wilson et al.
  4. Principled Data Processing, Patrick Ball.
  5. The Plain Person’s Guide to Plain Text Social Science, Healy.
  6. Avoiding technical debt in social science research, Toor.
library(ggiraph)
library(maps)
shinyServer(function(input, output, session) {
selected_car <- reactive({
if( is.null(input$plot_selected)){
character(0)
} else input$plot_selected
@conormm
conormm / r-to-python-data-wrangling-basics.md
Last active April 24, 2024 18:22
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

@kittenlane
kittenlane / 1-remove-woocommerce-tabs.php
Last active November 30, 2023 20:07
Remove tabs but keep product description in WooCommerce
//* http://gasolicious.com/remove-tabs-keep-product-description-woocommerce/
// Location: add to functions.php
// Output: removes woocommerce tabs
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
@maltefl
maltefl / fractalgan.py
Created February 21, 2012 18:55 — forked from smukkejohan/chaossearh.py
Python port of Paul Bourke's random strange attractor generator using lyapunov exponents
# Python port of Paul Bourke's http://local.wasp.uwa.edu.au/~pbourke/fractals/lyapunov/gen.c
# By Johan Bichel Lindegaard - http://johan.cc
import math
import random
from PIL import Image, ImageDraw
import argparse
import os
parser = argparse.ArgumentParser(description='Search for chaos.')