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(stringr) | |
| require(visNetwork) | |
| candy <- read_csv("candyhierarchy2017.csv") | |
| names(candy) <- names(candy) %>% str_replace_all("\\\\xd5", "") | |
| balanced_candy <- candy %>% | |
| mutate(total_na = candy %>% | |
| select(starts_with("Q6")) %>% |
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(shiny) | |
| library(shinythemes) | |
| library(shinysense) | |
| library(tidyverse) | |
| ui <- fluidPage( | |
| theme = shinytheme("flatly"), | |
| fluidRow( | |
| column(width = 5, | |
| h4("Drawn coefficients"), shinydrawrUI("outbreak_stats")), |
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) | |
| one_hot <- function(data, var) { | |
| var_enquo <- enquo(var) | |
| items <- data %>% pull(!!var_enquo) | |
| items_unique <- items %>% unique() | |
| out <- matrix(0, NROW(data), length(items_unique)) | |
| colnames(out) <- items_unique |
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) | |
| one_hot <- function(data, var) { | |
| var_enquo <- enquo(var) | |
| items <- data %>% pull(!!var_enquo) | |
| items_unique <- items %>% unique() | |
| out <- matrix(0, NROW(data), length(items_unique)) | |
| colnames(out) <- items_unique |
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(rvest) | |
| library(tidyverse) | |
| library(lubridate) | |
| library(glue) | |
| #library(ehlib) # devtools::install_github("EmilHvitfeldt/ehlib") | |
| str_between <- function(string, start, end) { | |
| stringr::str_extract(string, | |
| stringr::str_c(start, '(.*?)', end, collapse = '')) %>% | |
| stringr::str_replace(start, "") %>% |
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(tidytext) | |
| library(purrrlyr) | |
| str_nth_word <- function(x, n, sep = " ") { | |
| str_split(x, pattern = " ") %>% | |
| map_chr(~ .x[n]) | |
| } | |
| sigmoid <- function(x_from, x_to, y_from, y_to, scale = 5, n = 100) { |
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(maps) | |
| library(tidyverse) | |
| # Having the data.csv file in the same working directory | |
| data <- read_csv("data.csv") | |
| data_states <- data %>% | |
| mutate(state = map.where('state', Longitude, Latitude)) %>% | |
| # Removes point not in a state |
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
| # Packages | |
| library(Rvision) | |
| library(dplyr) | |
| library(lubridate) | |
| # Functions | |
| blob_fun <- function(img, fun, color = character()) { | |
| img %>% | |
| split() %>% | |
| do.call(fun, .) %>% |
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(ggrepel) | |
| set.seed(1234) | |
| data <- tibble(x = seq_len(100), | |
| y = cumsum(rnorm(100))) | |
| anno_data <- data %>% | |
| filter(x %% 25 == 10) %>% |
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
| geom_heart <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", | |
| ..., parse = FALSE, nudge_x = 0, nudge_y = 0, check_overlap = FALSE, | |
| na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) | |
| { | |
| if (!missing(nudge_x) || !missing(nudge_y)) { | |
| if (!missing(position)) { | |
| stop("Specify either `position` or `nudge_x`/`nudge_y`", | |
| call. = FALSE) | |
| } | |
| position <- position_nudge(nudge_x, nudge_y) |
OlderNewer