I hereby claim:
- I am alistaire47 on github.
- I am alistaire (https://keybase.io/alistaire) on keybase.
- I have a public key ASCDokqb8qC26I5KvdqBatfUEG1x_I_64tywK32tK-CSrAo
To claim this, I am signing this object:
library(rvest) | |
library(purrr) | |
url <- 'http://www.basketball-reference.com/boxscores/201506140GSW.html' | |
tables <- url %>% read_html() %>% html_nodes('.sortable.stats_table') | |
headers <- tables %>% html_nodes(xpath = 'thead/tr[@class=""]') %>% | |
map(html_nodes, 'th') %>% | |
map(html_text) |
I hereby claim:
To claim this, I am signing this object:
library(rvest) | |
library(tidyverse) | |
h <- read_html('https://projects.fivethirtyeight.com/congress-trump-score/house/') | |
trump_score <- h %>% | |
html_nodes('table.member-list') %>% | |
map(html_table, fill = TRUE) %>% | |
set_names(c('Senate', 'House')) %>% | |
map(set_names, |
# base R version | |
read.markdown <- function(file, stringsAsFactors = FALSE, strip.white = TRUE, ...){ | |
if (length(file) > 1) { | |
lines <- file | |
} else if (grepl('\n', file)) { | |
con <- textConnection(file) | |
lines <- readLines(con) | |
close(con) | |
} else { | |
lines <- readLines(file) |
--- | |
title: "Pythagorean Triples" | |
author: "Edward Visel" | |
output: | |
html_document: | |
df_print: paged | |
--- | |
```{r} | |
library(tidyverse) |
coalesce_join( | |
tribble( | |
~key, ~var1, ~var2, | |
'a', 1, NA, | |
'b', NA, 2 | |
), | |
tribble( | |
~key, ~var1, ~var2, | |
'a', NA, 1, | |
'b', 2, NA |
library(dplyr) | |
library(ggplot2) | |
library(gganimate) | |
### Horizontal rotation | |
p <- data_frame(x = c(-4, 0, 4), y = c(0, 3, 0), state = 1) %>% | |
bind_rows(mutate(., x = -x, state = 2)) %>% # frame flipped over y-axis | |
ggplot(aes(x, y, ymin = y, ymax = y + 1)) + | |
geom_ribbon() + |
library(tidyverse) | |
library(gganimate) | |
p <- crossing(t = (1:4)*pi/2, | |
x = seq(0, 2*pi, length = 501)) %>% | |
mutate(y = 2 - 2*sin(x) + sin(x) * sqrt(abs(cos(x)))/(sin(x) + 1.4), | |
x = (x + t) %% (2*pi)) %>% | |
ggplot(aes(x, y, color = x)) + | |
geom_path(size = 2, show.legend = FALSE) + | |
scale_color_gradient2(low = '#7a0177', mid = '#f768a1', high = '#fcc5c0') + |
library(tidyverse) | |
library(gganimate) | |
animate( | |
crossing( | |
p = seq(0.1, 5, by = 0.1), | |
theta = seq(0, 2*pi, length.out = 101) | |
) %>% | |
mutate(r = 1 / (abs(cos(theta))^p + abs(sin(theta))^p)^(1/p)) %>% | |
ggplot(aes(theta, r, fill = p)) + |
alistaire <- function(n){ | |
two_rows <- rep(seq_len(n/2L), each = 4L) | |
out_mat <- matrix(0L, n, n) | |
index_mat <- matrix(seq_len(n), nrow = 2L) | |
for (i in seq_len(n/2L)){ | |
out_mat[index_mat[, i], ] <- two_rows | |
two_rows <- two_rows + 1L | |
} | |
out_mat | |
} |