-
This is a numbered list.
-
I'm going to include a fenced code block as part of this bullet:
Code More Code
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") | |
#' Draw Normal Distribution Density with an area shaded in. | |
#' | |
#' @param lb Lower bound of the shaded area. Use \code{-Inf} for a left tail. | |
#' @param ub Upper bound of the shaded area. Use \code{Inf} for a right tail. | |
#' @param mean Mean of the normal distribution | |
#' @param sd Standard deviation of the normal distribution | |
#' @param limits Lower and upper bounds on the x-axis of the area displayed. | |
#' @return ggplot object. |
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
catDf <- data.frame(meow = rnorm(100), purr = rpois(100, 3)) | |
aList <- list(aVector = 1:20, aDf = catDf, anotherList = list(1:200, 1:20)) | |
# annoying as hell, right? | |
head(aList) | |
#' Return the first or last part of a list | |
#' | |
#' Returns the first or last part of a list. Instead of returning the first | |
#' n entries as the standard head() does, it attempts to call head() |
2017-08-03: Since I wrote this in 2014, the universe, specifically Kirill Müller (https://github.com/krlmlr), has provided better solutions to this problem. I now recommend that you use one of these two packages:
- rprojroot: This is the main package with functions to help you express paths in a way that will "just work" when developing interactively in an RStudio Project and when you render your file.
- here: A lightweight wrapper around rprojroot that anticipates the most likely scenario: you want to write paths relative to the top-level directory, defined as an RStudio project or Git repo. TRY THIS FIRST.
I love these packages so much I wrote an ode to here.
I use these packages now instead of what I describe below. I'll leave this gist up for historical interest. 😆
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
--- | |
title: "Untitled" | |
author: "Francisco Rodriguez-Sanchez" | |
date: "Thursday, January 22, 2015" | |
output: html_document | |
--- | |
<style type="text/css"> | |
body, td { |
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
#!/bin/bash | |
# | |
# Installs the latest RStudio daily desktop build for OSX/macOS and Ubuntu(amd64) | |
# | |
# https://support.rstudio.com/hc/en-us/articles/203842428-Getting-the-newest-RStudio-builds | |
set -e | |
install_macos_daily() { | |
REDIRECT_URL="https://www.rstudio.org/download/latest/daily/desktop/mac/RStudio-latest.dmg" |
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
#' @title Mosaic plot using ggplot. | |
#' | |
#' @description | |
#' Creates a mosaic plot where the dimensions of the cells of a | |
#' confusion matrix represent their marginal proportions. | |
#' | |
#' @details | |
#' Credit for initial iteration to | |
#' [Edwin](http://stackoverflow.com/a/19258045/992999) | |
#' This version adds color brewer options and tidies the labelling |
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
# On macOS Anki media files are stored in ~/Library/Application Support/Anki2/Username/collection.media/ | |
# https://apps.ankiweb.net/docs/manual.html#file-locations | |
# get images from Unconf repo, resize them and write them to the new path | |
# Code assumes it is being run on macOS from the checkout of the conference repo, e.g. `git clone https://github.com/ropensci/unconf18 && cd unconf18` | |
library(fs) | |
library(magick) | |
imgs <- dir_ls("images/participants") | |
for (f in imgs) { | |
f %>% | |
image_read() %>% |