Skip to content

Instantly share code, notes, and snippets.

@sj-io
sj-io / CLAUDE.md
Created August 21, 2025 09:25
Claude R Tidyverse Expert

Modern R Development Guide

This document captures current best practices for R development, emphasizing modern tidyverse patterns, performance, and style. Last updated: August 2025

Core Principles

  1. Use modern tidyverse patterns - Prioritize dplyr 1.1+ features, native pipe, and current APIs
  2. Profile before optimizing - Use profvis and bench to identify real bottlenecks
  3. Write readable code first - Optimize only when necessary and after profiling
  4. Follow tidyverse style guide - Consistent naming, spacing, and structure
library(ggplot2)
library(dplyr)
library(tidyr)
library(stringr)
library(scales)
library(gridExtra)
library(grid)
# use the NPR story data file ---------------------------------------------
# and be kind to NPR's bandwidth budget
@somada141
somada141 / python_dicom_load_pydicom.md
Created March 2, 2015 10:30
Load DICOM data into a NumPy array with PyDICOM #python #dicom #medical #imagedata #pydicom #fileIO
@yihui
yihui / README.md
Last active March 15, 2017 18:35
A Shiny app based on annyang that responds to voice input
@randyzwitch
randyzwitch / rsitecatalyst-sankey-one-page.R
Created September 10, 2014 20:42
RSiteCatalyst Sankey Diagram - Single Page to Multiple Pages
library("RSiteCatalyst")
library("d3Network")
#### Authentication
SCAuth("key", "secret")
#### Get Pathing data: Single page, then ::anything:: pattern
pathpattern <- c("http://randyzwitch.com/big-data-hadoop-amazon-ec2-cloudera-part-1", "::anything::")
next_page <- QueuePathing("zwitchdev",
"2014-01-01",
library(MCMCpack)
## Coping with polls: the more recent, the better they are.
##http://en.wikipedia.org/wiki/Opinion_polling_for_the_Scottish_independence_referendum,_2014
polls = NULL
polls <- data.frame( rbind(
Survation = c(37, 50, 1010),
YouGov = c(35, 55, 1142),
TNSBMRB = c(32, 45, 1003),
IpsosMORI = c(40, 54, 1006),
require(ipeds)
require(ggplot2)
require(reshape2)
require(scales)
data(surveys)
View(surveys)
# Directory
ipedsHelp('HD', 2012)
library(plyr)
library(ggplot2)
library(ggmap)
libraries = read.csv("ontario_library_stats_2010.csv")
libraries$isFN = ifelse(libraries$Library.Service.Type == "First Nations Library",1,0)
# Here we create the 'proportionate' versions of all the variables
libraries[,143:265] = sapply(libraries[,20:142], function (x) x/libraries[,13])
names(libraries)[143:265] = paste(names(libraries)[20:142], "P",sep=".")
@blmoore
blmoore / plos_authInflation.R
Last active June 28, 2018 15:00
For blog post
options(PlosApiKey = "<insert your API key here!>")
#install_github("rplos", "ropensci")
library("rplos")
library("ggplot2")
require("dplyr")
# Convert author strings to counts
countAuths <- function(cell)
length(unlist(strsplit(cell, ";")))