-
Dropping attributes
matrix[, 1, drop=FALSE]
-
Autocompletion for thee but not for me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"c": "c_cpp", | |
"c++": "c_cpp", | |
"c#": "csharp", | |
"f#": "fsharp", | |
"fortran free form": "fortran", | |
"gradle": "groovy", | |
"json with comments": "json", | |
"rmarkdown": "markdown", | |
"shell": "bash", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("ggplot2") | |
library("ggdist") | |
library("latex2exp") | |
set.seed(42) | |
means <- rnorm(4) | |
df_slabplot <- rbind( | |
data.frame( | |
method = "hmc", | |
bj = rnorm(4000, mean = rep(means, each = 1000)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## using natbib | |
## when finished adding refs, run | |
bibexport --nosave -o [LOCAL_BIB_FILE] main.aux | |
## then switch the \bibliography command from the central file to the local one, ie change | |
# % \bibliography{[CENTRAL_BIB_FILE]} | |
# % \bibliography{[LOCAL_BIB_FILE]} | |
# % with biblatex you would run something like | |
jabref -n --aux main.aux,[LOCAL_BIB_FILE] [CENTRAL_BIB_FILE] | |
## and again switch which bib file you're working with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
if [ -f ~/miniconda3/etc/profile.d/conda.sh ]; then | |
[ -z "${CONDA_EXE}" ] && echo "Error, missing \$CONDA_EXE !" && exit 1 | |
CONDA_BASE=$(${CONDA_EXE} info --base) | |
ADDR2LINE="" | |
source $CONDA_BASE/etc/profile.d/conda.sh | |
conda activate $1 || exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(utils) | |
for (pkg in rownames(installed.packages(priority="base"))) library(pkg, character.only=TRUE) | |
pkgs <- c( | |
"NHANES", | |
"RNHANES", | |
"ggplot2", | |
"jtools", | |
"interactions", | |
"patchwork", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# R port of Dmitry Kobak's excellent PCA animations. | |
# See https://gist.github.com/anonymous/7d888663c6ec679ea65428715b99bfdd | |
# for matlab/octave code | |
dir.create("gif", showWarnings = FALSE) | |
set.seed(42) | |
X <- matrix(rnorm(200), ncol = 2) | |
X <- X %*% chol(matrix(c(1, 0.6, 0.6, 0.6), ncol = 2, byrow = TRUE)) | |
X <- apply(X, 2, function(col) col - mean(col)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("scRNAseq") | |
library("scater") | |
library("scran") | |
library("flexmix") | |
library("mixtools") | |
library("viridis") | |
library("annotables") | |
theme_set(theme_bw()) | |
sce <- ZeiselBrainData() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("ggplot2") | |
library("usmap") | |
library("httr") | |
library("readxl") | |
# Read data | |
GET("https://query.data.world/s/pth2w34nwc6uhg7mmvr7n56257y2gw", write_disk(tf <- tempfile(fileext = ".xlsx"))) | |
pets <- read_excel(tf) | |
pets <- pets[!colnames(pets) %in% "X"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################ | |
# Syntax highlighting for R # | |
# by Stephen Haptonstahl # | |
# March 15, 2009 # | |
# http://srh.ucdavis.edu/drupal/node/20 # | |
# edited by Mike Miller # | |
# Placed on GitHub by Alan O'Callaghan # | |
# (could no longer find the original) # | |
############################################ |
NewerOlder