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: "googleVis test" | |
author: "Matt Dray" | |
date: "23/04/2019" | |
output: html_document | |
--- | |
Set up example dataframe from [the {googleVis} examples](https://cran.r-project.org/web/packages/googleVis/vignettes/googleVis_examples.html) CRAN vignette. | |
```{r} |
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
# Packages | |
library(brickr) | |
library(rayshader) | |
library(tibble) | |
# Function that takes colours for different parts of the player model. | |
# Colour codes as per brickr::lego_colors | |
# Output is a bricks_from_table() list object | |
# Output should be fed to display_bricks() |
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
# Create a soccer player using {brickr} | |
# This file specifies some colour combinations for certain teams | |
# Blog post: https://www.rostrum.blog/2019/05/31/brickr-soccer/ | |
# You need to load some packages | |
# library(brickr) | |
# library(dray) # from remotes::install_github("matt-dray/dray") | |
# After creating a colour specification, pass it to | |
# bricks_from_table() %>% display_bricks() to render it |
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
# This isn't optimal and there's probably | |
# a function that does all this already | |
# Packages | |
library(dplyr) | |
library(purrr) | |
library(tibble) | |
# Write function | |
get_expansion <- function(x, y) { |
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
--- | |
<details><summary>Session info</summary> | |
```{r sessioninfo, echo=FALSE} | |
paste("Last updated", Sys.Date()) | |
xfun::session_info() | |
``` | |
</details> |
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) |