Skip to content

Instantly share code, notes, and snippets.

@fkeck
fkeck / rgpt
Created March 28, 2023 18:18
Experiment with ChatGPT to generate R code from natural language
describe_data_df <- function(x) {
res_1 <- paste0("data is a dataframe with ", ncol(x), " colums", ":")
res_2 <- sapply(x, class)
res_2 <- sapply(1:length(res_2), function(x) {
paste0("- Column ", x, " is named '", names(res_2)[x], "' and is of class ", res_2[x], ".")
})
res_2 <- paste(res_2, collapse = "\n")
res <- paste(res_1, res_2, sep = "\n")
@gadenbuie
gadenbuie / join-animations-with-gganimate.R
Last active January 11, 2022 15:48
Animated dplyr joins with gganimate
# Animated dplyr joins with gganimate
# * Garrick Aden-Buie
# * garrickadenbuie.com
# * MIT License: https://opensource.org/licenses/MIT
# Note: I used Fira Sans and Fira Mono fonts.
# Use search and replace to use a different font if Fira is not available.
library(tidyverse)
library(gganimate)
@max-mapper
max-mapper / bibtex.png
Last active November 19, 2025 13:01
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png
# data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
# Originally seen at http://spatial.ly/2014/08/population-lines/
# So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess,
# and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after
# @hadleywickham pointed that out. Also, switched from geom_segment to geom_line.
# The result of the code below can be seen at http://imgur.com/ob8c8ph
library(tidyverse)
@caseywdunn
caseywdunn / docker.md
Last active August 10, 2023 18:13
Docker cheat sheet

Docker cheat sheet

Introduction

Docker is a tool for bundling together applications and their dependencies into images that can than be run as containers on many different types of computers.

Docker and other containerization tools are useful to scientists because:

  • It greatly simplifies distribution and installation of complex work flows that
@sdtaylor
sdtaylor / install_old_packages.R
Last active April 24, 2017 22:29
Install all the packages that were in the prior version of R
prior_version = 3.3
library_path = .libPaths()[1]
library_path = substr(library_path, 1, nchar(library_path)-3)
old_library_path=paste0(library_path, prior_version)
old_packages = list.files(old_library_path)
install.packages(old_packages)
@ctb
ctb / README.md
Created February 15, 2015 12:00
Reproducibility workflow workshop at MSU - description

Seminar Topic: Reproducible Computational Analysis - How to start a new project

Time: March 24, 2015 from 9:00am- 12:00 noon
Location: Biomedical & Physical Sciences Bldg, Room 2245 Instructor: Dr. Titus Brown

Description

Computational science projects, from data analysis to modeling, can benefit dramatically from a little up-front investment in automation; starting off with version control and automated building of results will pay off in efficiency, agility, and both transparency and reproducibility of the results. However, most computational researchers have never been exposed to a completely automated analysis pipeline. I will demonstrate the process of initiating a new project, building a few initial scripts, and automating the generation of results, as well as building some graphs. While the topic will be from my own research in bioinformatics, the overall approach should apply to anyone doing data analysis or simulations.

@pbugnion
pbugnion / ipython_notebook_in_git.md
Last active December 4, 2025 22:24
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.