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
alias.hist=log --decorate --oneline --graph --all |
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
# all.equal() behaves differently when presented with objects of class | |
# data.frame versus those with tibble class. This is important for | |
# trying to rewrite the {tidyr} episode of Software Carpentry's | |
# R for Reproducible Scientific Analysis lesson to include the new | |
# pivot_wider() and pivot_longer() columns instead of spread() and | |
# gather(), which have been superseded. | |
# Seems to be a noted problem: | |
# https://github.com/tidyverse/tibble/issues/287 |
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
cd /Users/matthewdray/.bash_profile |
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
# Import re for working with regular expressions | |
import re | |
# Provide some text to search | |
# 'Hipster ipsum' via https://hipsum.co/ | |
text = "Lorem ipsum dolor amet selfies williamsburg tattooed ethical wolf cloud bread. Cronut marfa heirloom pour-over. Jean shorts aesthetic before they sold out, yr subway tile kale chips occupy. Banjo lomo af, meditation roof party cronut vape glossier." | |
# Search for a specific phrase | |
# Returns a 'match' object | |
# More info here: https://www.w3schools.com/python/python_regex.asp#matchobject |
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
# Basic use of the {officer} package to scrape a table from a Word doc | |
# https://davidgohel.github.io/officer/ | |
# I've now written a couple of functions to do this task: | |
# https://gist.github.com/matt-dray/d4837f106bcee80ea39235b6465a7cac | |
# You can read more about those in a blog post: | |
# https://www.rostrum.blog/2023/06/07/rectangular-officer/ | |
# There are other solutions. You can also try {docxtractr} by Bon Rudis | |
# (on CRAN), which doesn't depend on {officer}, or {officerExtras} by Eli |
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(magick) | |
before <- image_read("~/Desktop/before.png") | |
before <- image_crop(before, "815x300-80-200") | |
after <- image_crop(image_read("~/Desktop/after.png")) | |
after <- image_crop(after, "815x300-80-200") | |
# To morph | |
# frames <- image_morph(c(before, after, before), frames = 20) |
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(dplyr) | |
library(tidyr) | |
data <- tibble( | |
var1 = c(rep("A", 3), rep("B", 2)), | |
var2 = c(letters[1:3], letters[1:2]), | |
var3 = runif(5) | |
) | |
expand(data, var1, var2) %>% |
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
# Plot weight by cylinders, with weight by gear inside | |
# Using {ggpattern} by @coolbutuseless | |
# https://coolbutuseless.github.io/package/ggpattern/ | |
# Tongue-in-cheek blog post: https://www.rostrum.blog/2020/04/05/yo-dawg/ | |
# Load packages | |
library(dplyr) | |
library(purrr) | |
library(tidyr) | |
library(ggplot2) |
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
# Question: how can content of vars() be supplied to set_names() after a map()? | |
# Also: below, can variables_bare be coerced to variables_quoted, or vice-versa? | |
# Load packages | |
suppressPackageStartupMessages(library(dplyr)) | |
library(purrr) | |
# Quoted and unquoted vectors | |
variables_bare <- vars(Sepal.Width, Petal.Length) # to be passed to .x in map() | |
variables_quoted <- c("Sepal.Width", "Petal.Length") # as above, quoted version |
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: "Crosstalk test" | |
output: | |
html_document: | |
code_folding: hide | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
library(crosstalk) |