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
sq <- ggplot((na.omit(threats)), aes(factor(soil_quality)))+ geom_bar() + facet_grid(~Gender) + aes(fill = Gender) | |
wq <- ggplot((na.omit(threats)), aes(factor(waterquality))) + geom_bar()+ facet_grid(~Gender) + aes(fill = Gender) | |
wl <- ggplot((na.omit(threats)), aes(factor(wildlife))) + geom_bar()+ facet_grid(~Gender) + aes(fill = Gender) | |
rec <- ggplot((na.omit(threats)), aes(factor(recreation))) + geom_bar() + facet_grid(~Gender) + aes(fill = Gender) | |
scen <- ggplot((na.omit(threats)), aes(factor(scenic))) + geom_bar() + facet_grid(~Gender) + aes(fill = Gender) | |
tour <- ggplot((na.omit(threats)), aes(factor(tourism))) + geom_bar() + facet_grid(~Gender) + aes(fill = Gender) | |
biz <- ggplot((na.omit(threats)), aes(factor(business))) + geom_bar() + facet_grid(~Gender) + aes(fill = Gender) | |
rur <- ggplot((na.omit(threats)), aes(factor(rural))) + geom_bar() + facet_grid(~Gender) + aes(fill = Gender) | |
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
# Create a tibble with the artist's name & another with the album title | |
kdot_albums <- tibble( | |
artist = "Kendrick Lamar", | |
album = c("Section 80", "DAMN.")) | |
# Iterate through the albums and artists using a map call | |
album_lyrics <- kdot_albums %>% | |
mutate(tracks = map2(artist, album, genius_album)) |
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(genius) | |
library(tidytext) | |
library(tidyverse) | |
# get lyrics for album | |
since_96 <- genius_album("ALIX", "since 96") | |
# calculate self similarity by group (thank you dplyr v 0.8!!!) | |
self_sim_96 <- since_96 %>% |
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
# create function for getting song features | |
track_audio_features <- function(artist, title, type = "track") { | |
search_results <- search_spotify(paste(artist, title), type = type) | |
track_audio_feats <- get_track_audio_features(search_results$id[[1]]) %>% | |
dplyr::select(-id, -uri, -track_href, -analysis_url) | |
return(track_audio_feats) | |
} | |
# create a version of this function which can handle errors |
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(trendyy) | |
library(tidyverse) | |
candidates <- c("joe biden", "kamala harris", "elizabeth warren", "pete buttigieg", "cory booker") | |
candidate_trends <- trendy(candidates, from = "2019-06-15", to = Sys.Date()) | |
get_interest(candidate_trends) %>% | |
filter(date >= "2019-06-25") %>% | |
ggplot(aes(date, hits, color = keyword)) + |
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(jsonlite) | |
res <- GET("http://api.themoviedb.org/3/discover/movie?release_date.gte=2017-12-01&release_date.lte=2017-12-31&api_key=606aaffd7ca10f0b80804a1f0674e4e1&page=1") %>% | |
content("text") %>% | |
fromJSON() | |
int0_to_na <- function(x) { |
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
--- | |
title: "∑ { _my parts_ }" | |
output: github_document | |
--- | |
```{r message=FALSE, warning=FALSE} | |
library(tidyverse) | |
terrorists <- googlesheets::gs_url("https://docs.google.com/spreadsheets/d/1LYQakIwGosibDHJKJqZgjM39qpSlp_gFG29zJ6paDAI/edit#gid=956062857") %>% | |
googlesheets::gs_read() |
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(sqldf) | |
library(tidyverse) | |
polls <- read_csv("https://raw.githubusercontent.com/JosiahParry/r-4-campaigns/master/data/polls.csv") | |
sqldf("select candidate, count(*) as n | |
from polls | |
where points > 20 | |
group by candidate |
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
track_audio_features <- possibly(.f = { | |
function(artist, title, type = "track") { | |
search_results <- search_spotify(paste(artist, title), type = type) | |
track_audio_feats <- get_track_audio_features(search_results$id[[1]]) %>% | |
dplyr::select(-id, -uri, -track_href, -analysis_url) | |
return(track_audio_feats) | |
}}, otherwise = tibble()) |
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) | |
dice_words <- read_tsv("https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt", | |
col_names = c("dice_id", "dice_word"), col_types = "cc") | |
diceware <- function(n_words) { | |
map_dfr(1:n_words, ~tibble(dice_id = paste(sample(1:6, 5, replace = TRUE), collapse = ""))) %>% | |
left_join(dice_words) | |
} |
OlderNewer