
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(gh) | |
library(tidyverse) | |
library("magick") | |
library(glue) | |
dir.create("data") | |
repos <- gh::gh("/orgs/:org/repos", org = "tidyverse", .limit = Inf) %>% map_chr("name") | |
urls <- repos %>% |
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) | |
# data from https://www.kaggle.com/bls/american-time-use-survey | |
df.resp <- read_csv('../data/atus/atusresp.csv') | |
df.act <- read_csv('../data/atus/atusact.csv', col_types=cols(tustarttim = col_character(), tustoptime = col_character())) | |
df.sum <- read_csv('../data/atus/atussum.csv') | |
df.tmp <- df.act %>% | |
mutate(activity = case_when(trtier2p == 1301 ~ 'Exercise', |
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(magick) | |
library(magrittr) | |
# Convert to 'ico' format | |
image_read("https://www.r-project.org/logo/Rlogo.png") %>% | |
image_scale("32x32!") %>% # remove the "!" after 32x32 to scale proportionally | |
image_write("favicon.ico", format = "ico") | |
# Favicon can also be png/gif |
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(idbr) | |
library(ggplot2) | |
library(gganimate) | |
library(tweenr) | |
library(countrycode) | |
library(dplyr) | |
idb_api_key("Your API key goes here") | |
africa_fips <- countrycode(c('Nigeria', 'Uganda', 'Tanzania', 'Ghana'), |
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
```r | |
p_load_gh("jcheng5/bubbles", "trinker/qdapTools") | |
x <- runif(26) | |
colfunc <- colorRampPalette(c("white", "red")) | |
cols <- colfunc(length(sort(unique(x)))) | |
bubbles(value = x, label = LETTERS, |
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(rgdal) | |
library(rgeos) | |
library(ggplot2) | |
library(readr) | |
library(tidyr) | |
library(dplyr) | |
library(grid) | |
us <- readOGR("us_states_hexgrid.geojson", "OGRGeoJSON") |
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
### Parsing Netsdaily for a Polarity Plot -- working with JSON | |
packages <- | |
c('magrittr', 'dplyr', 'qdap', 'jsonlite', 'ggplot2') | |
lapply(packages, library, character.only = T) | |
url <- | |
'http://www.netsdaily.com/comments/load_comments/8261850' | |
data <- | |
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
# Twitter Topic Modeling Using R | |
# Author: Bryan Goodrich | |
# Date Created: February 13, 2015 | |
# Last Modified: April 3, 2015 | |
# | |
# Use twitteR API to query Twitter, parse the search result, and | |
# perform a series of topic models for identifying potentially | |
# useful topics from your query content. This has applications for | |
# social media, research, or general curiosity | |
# |
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
import array | |
class WeightedQuickUnion: | |
def __init__(self, N): | |
self.count = N | |
self.id = array.array('i', range(N)) | |
self.size = array.array('i', [1] * N) | |
def connected(self, p, q): | |
return self.find(p) == self.find(q) |
NewerOlder