This file contains hidden or 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
### Checking 'expandrows' function: | |
## Subsetted example dataset: | |
mydf <- structure(list(Timestamp = c("2/25/2015 15:14:09", "2/25/2015 15:16:49", | |
"2/25/2015 15:17:06", "2/25/2015 15:18:10", "2/25/2015 15:20:16", | |
"2/25/2015 15:21:34", "3/1/2015 14:47:32", "3/1/2015 14:49:00", | |
"3/1/2015 14:50:50", "3/1/2015 14:56:46", "3/1/2015 14:58:08" | |
), Actor = c("23", "15, 28", "6", "27", "23", "29", "30", "13", | |
"26", "13", "20"), Behavior = c("Fighting", "Fighting", "Chasing", |
This file contains hidden or 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
### Waffle Charts | |
#install waffle & rcdimple | |
devtools::install_github("timelyportfolio/rcdimple") # only for htmlwidget functionality | |
devtools::install_github("hrbrmstr/waffle") | |
library(waffle) | |
#data |
This file contains hidden or 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
### Playing around with waffle function to change where the blocks start from / finish | |
wafflex <- function (parts, rows = 10, xlab = NULL, title = NULL, colors = NA, | |
size = 2, flip = FALSE, reverse = FALSE, equal = TRUE, pad = 0, from = NULL) | |
{ | |
part_names <- names(parts) | |
if (length(part_names) < length(parts)) { | |
part_names <- c(part_names, LETTERS[1:length(parts) - | |
length(part_names)]) |
This file contains hidden or 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
#### Putting rphylopics into a waffle type chart | |
### WARNING - I know this code is a bit 'hacky' - I was just trying to make it work. | |
### There are likely better ways to do it, but this is how I got it up and running. | |
library(rphylopic) | |
#get phylopics | |
bird1<-get_image("23c63b97-e0ab-4b43-89a4-e2358f4f09ec", size="64")[[1]] | |
bird2<-get_image("abab8520-b72b-4ecb-97fd-945f8675fe61", size="64")[[1]] |
This file contains hidden or 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
#### Multidimensional Scaling aka Principal Coordinates Analysis | |
# Multidimensional scaling takes a set of dissimilarities and returns a set of points such that the | |
# distances between the points are approximately equal to the dissimilarities. | |
### Example 1 - from rbloggers - http://www.r-bloggers.com/multidimensional-scaling-mds-with-r/ | |
#get data |
This file contains hidden or 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
#### Some simple Principal Components Analysis | |
# from Gaston Sanchez website | |
USArrests | |
# PCA with function prcomp | |
pca1 = prcomp(USArrests, scale. = TRUE) | |
# sqrt of eigenvalues | |
pca1$sdev |
This file contains hidden or 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
### load packages | |
library(babynames) | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(gridExtra) | |
library(magrittr) | |
head(babynames) |
This file contains hidden or 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
### Cumulative Golf Major Winners | |
library(XML) | |
masters <- readHTMLTable("http://en.wikipedia.org/wiki/Masters_Tournament") | |
masters <- masters[[4]][,1:2] | |
usopen <- readHTMLTable("http://en.wikipedia.org/wiki/U.S._Open_(golf)") | |
usopen <- usopen[[2]][,1:2] |
This file contains hidden or 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
### NHL PLAYOFF SIM by jalapic | |
library(dplyr) | |
library(PlayerRatings) | |
library(magrittr) | |
#copy and paste initial ELO ratings from nhlelo shiny app | |
ratings<- | |
read.table(text=" |
This file contains hidden or 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
### NHL PLAYOFF SIM | |
library(dplyr) | |
library(PlayerRatings) | |
library(magrittr) | |
library(ggplot2) | |
library(curleylab) #only using this for ggplot theme - not necessary to install if don't want. just remove 'curleytheme' in plot | |
#copy and paste initial ELO ratings from my nhlelo shiny app | |
# https://jalapic.shinyapps.io/nhlelo/# |