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(ggplot2) ## devtools::install_github("hadley/ggplot2) | |
| library(grid) ## rasterGrob | |
| library(EBImage) ## readImage | |
| library(ggthemes) ## theme_minimal | |
| ## ########## | |
| ## INDEPENDENT CODE TO BE SOURCED: | |
| ## ########## | |
| # user-level interface to the element grob |
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(ggplot2) ## devtools::install_github("hadley/ggplot2) | |
| library(grid) ## rasterGrob | |
| library(EBImage) ## readImage | |
| library(ggthemes) ## theme_minimal | |
| ## ########## | |
| ## INDEPENDENT CODE TO BE SOURCED: | |
| ## ########## | |
| # user-level interface to the element grob |
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
| pacman::p_load(tidyverse, ggrepel) | |
| set.seed(10) | |
| norah <- data_frame( | |
| right = c(4, 7, 2, 9, 6, 3, 8, 10), | |
| up = c(10, 8, 3, 6, 9, 2, 7, 4), | |
| size = c(1, 1, 2, 3, 4, 9, 8, 7), | |
| high = sample(size), | |
| friends = c('Makayla', 'Ethan', 'Jolene', "Maddy", "Isla", "Daddy", "Norah", "Lila"), |
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) | |
| set.seed(11) | |
| dat <- data_frame( | |
| stage = LETTERS[1:7], | |
| n = sample(20:100, length(stage)) | |
| ) | |
| dat %>% | |
| mutate( |
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
| if (!require("pacman")) install.packages("pacman") | |
| pacman::p_load_gh("ropensci/RSelenium") | |
| pacman::p_load(httr, jsonlite, XML, RSelenium, curl, semver, rappdirs, subprocess, rvest, xml, geosphere, tidyverse) | |
| ## Constants | |
| hillsgrove <- data.frame(long = -76.710563, lat = 41.443678) | |
| earth_radius_miles <- 3959 #in miles | |
| ## Cities to lookup |
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
| pacman::p_load(tidyverse, textclean, textshape, textreadr, sentimentr, rvest, xml2, yaml) | |
| posts <- file.path('https://github.com/iacobus42/blog/tree/master/_posts') %>% | |
| read_html() %>% | |
| html_nodes(xpath = '//*[@id="js-repo-pjax-container"]/div[2]/div[1]/div[3]/table') %>% | |
| html_table() %>% | |
| `[[`(1) %>% | |
| select(X2) %>% | |
| slice(-c(1:2)) %>% | |
| unlist(use.names = FALSE) |
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
| pacman::p_load(termco, textshape, textclean, termco, xtable) | |
| pacman::p_load_current_gh('trinker/hilight') | |
| presidential_debates_2012 <- termco::presidential_debates_2012 | |
| #' See Terms in Context | |
| #' | |
| #' Examine regex term selections in the context of n rows before and after. | |
| #' | |
| #' @param x A data.frame with a text column. | |
| #' @param regex A regular expression that will be highlighted. |
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
| #' Add a Column as Rownames | |
| #' | |
| #' Takes an existing column and uses it as rownames instead. This is useful | |
| #' when turning a \code{\link[base]{data.frame}} into a \code{\link[base]{matrix}}. | |
| #' Inspired by the \pkg{tibble} package's \code{column_to_row} which is now | |
| #' deprecated. | |
| #' | |
| #' @param x An object that can be coerced to a \code{\link[base]{data.frame}}. | |
| #' @param loc The column location as either an integer or string index location. | |
| #' Must be unique row 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
| library(reshape2) | |
| library(ggplot2) | |
| data(mtcars) | |
| dat <- with(mtcars, data.frame(mpg, cyl, disp, hp, wt, gear)) | |
| cor.matrix <- round(cor(dat, use = "pairwise.complete.obs", method = "spearman"), digits = 2) | |
| diag(cor.matrix)<-NA | |
| cor.dat <- melt(cor.matrix) | |
| cor.dat <- data.frame(cor.dat) |
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
| check_install <- function(x, fun = 'function'){ | |
| found <- TRUE | |
| path <- try(find.package(x), silent = TRUE) | |
| if (inherits(path, "try-error")) found <- FALSE | |
| if (!found) { | |
| if (interactive()){ | |
| message(paste(x, "package not found. Do you want to install?\n")) | |
| ans <- utils::menu(c("Yes", "No")) |