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
| library(tidyverse) | |
| library(gganimate) | |
| f <- function(n, x) 1 - cos(2 * pi * n * x) | |
| g <- function(.f, x) map_dbl(x, ~integrate(function(z) .f(z), 0, .x)$value) | |
| df <- cross_df(list( | |
| x = seq(0, 1, length.out = 100), | |
| n = c(1, 2, 3, 5, 10, 15, 25) | |
| )) %>% |
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
| library(dplyr) | |
| library(tidyr) | |
| library(ggplot2) | |
| library(lubridate) | |
| library(stringr) | |
| library(rvest) | |
| library(xml2) | |
| library(OECD) | |
| # Get budget and box office 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
| # SPECIFIC PROBLEM: Extract an html table and include all links | |
| # (even when there are no links or multiple links per cell) | |
| # | |
| # GENERAL PROBLEM: Extract an html table and include all attributes | |
| # for any given tag and attribute | |
| # | |
| # Example usage at bottom of the page | |
| # | |
| # Motivation: https://twitter.com/daattali/status/717582654476914688 |
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
| library(httr) | |
| library(purrr) | |
| library(dplyr) | |
| library(ggplot2) | |
| library(scales) | |
| library(ggthemes) | |
| with_msg <- function(msg, f) { | |
| function(...) { |
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
| # Replicating https://t.co/Jq1QfFGpjA | |
| library(rvest) | |
| library(stringr) | |
| library(dplyr) | |
| library(tidyr) | |
| library(purrr) | |
| library(lubridate) | |
| get_and_clean_table <- function(url) { |
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
| library(dplyr); library(httr); library(rvest) | |
| addr <- "Big Ben" | |
| GET("http://maps.google.com/maps/api/geocode/xml", | |
| query = list(address = addr)) %>% | |
| content() %>% | |
| html_nodes(xpath = "//location//lat | //location//lng") %>% | |
| html_text() %>% | |
| setNames(c("lng", "lat")) |
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
| ## Purpose: illustrate use of magick, gganimate, and purrr | |
| ## Inspiration: | |
| ## https://rud.is/b/2016/07/27/u-s-drought-animations-with-the-witchs-brew-purrr-broom-magick/ | |
| ## and subsequent discussion on magick vs gganimate: | |
| ## https://twitter.com/hrbrmstr/status/758304420224466944 | |
| library(purrr) | |
| library(ggplot2) | |
| library(gganimate) | |
| library(animation) | |
| library(magick) |
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
| library(tidyverse) | |
| library(scales) | |
| library(stringr) | |
| library(grid) | |
| library(gridExtra) | |
| library(wikipediatrend) | |
| df <- wp_trend(c("R_(programming_language)", "Python_(programming_language)"), | |
| from = "2007-12-01", to = "2017-01-12") |
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
| library(eurostat) | |
| library(dplyr) | |
| library(ggplot2) | |
| library(scales) | |
| #### Original version (not using %+%) #### | |
| # Originally posted at http://www.r-bloggers.com/european-debt-and-interest/ on June 7, 2015 | |
| r1 <- get_eurostat('gov_10dd_edpt1') |
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
| library(tidyverse) | |
| library(patchwork) | |
| plot_pair <- function(data, x, y) { | |
| ggplot(data, aes_string(x = x, y = y, color = "Species", shape = "Species")) + | |
| geom_point() + | |
| scale_color_brewer(palette = "Dark2") + | |
| theme(legend.position = "none", plot.title = element_text(size = 7)) + | |
| labs(x = NULL, y = NULL, title = paste0(y, " ~ ", x)) |
NewerOlder