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
| markov_step <- function(island){ | |
| islands <- LETTERS[1:5] | |
| islands_pop <- list(A = 100, | |
| B = 200, | |
| C = 300, | |
| D = 400, | |
| E = 500) | |
| proposed_i <- sample(islands[islands != island], | |
| size = 1) |
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(MASS) | |
| library(patchwork) | |
| cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") | |
| # generate data with given cor matrix | |
| a <- 0.9 | |
| s1 <- matrix(c(1,a, | |
| a,1), ncol = 2) |
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(brickr) | |
| make_bricks <- function(brick_width = 5, | |
| brick_length = 5, | |
| n_layers = 3, | |
| colors = c("Bright red", | |
| "Bright green", | |
| "Bright blue"), | |
| render = FALSE){ | |
| x <- rep(sort(rep(1:brick_width, brick_length)), n_layers) |
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
| #libs | |
| library(tidyverse) | |
| #---CHELSEA--- | |
| # load in data | |
| california <- read.csv("./Data/namesbystate/STATE.CA.TXT", header = FALSE) | |
| colnames(california) <- c("State", "Gender", "Year", "Name", "Count") | |
| # filter data | |
| california_sub <- california %>% filter(Name == "Chelsea", Gender == "F") |
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(ggtext) | |
| library(grid) | |
| library(crayon) | |
| title <- "The <b><span style='color:#FF0000'>Sigmoid Function</span></b> and its <b><span style='color:#0000FF'>Derivative</span></b>" | |
| df <- data.frame(x = -5:5) | |
| ggplot(df, aes(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
| library(tidyverse) | |
| library(MASS) | |
| # plot e^x | |
| x <- -5:5 | |
| dat <- data.frame(x,y=exp(x)) | |
| f <- function(x) exp(x) | |
| p <- ggplot(dat, aes(x,y)) + | |
| stat_function(fun=f, colour="red") + |
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
| from shiny import App, render, ui, reactive | |
| from pathlib import Path | |
| # Import modules for plot rendering | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import pandas as pd |
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) | |
| # create named list | |
| l <- list(x = data.frame(a = rnorm(10), b = rnorm(10)), | |
| y = data.frame(a = rnorm(10), b = rnorm(10)), | |
| z = data.frame(a = rnorm(10), b = rnorm(10))) | |
| for (i in names(l)){ | |
| if (i %in% c("x", "y")){ # if the name of the list item is in a specified sublist | |
| l[[i]] <- l[[i]] %>% mutate(c = a + 1) # then do the 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
| library(readr) | |
| library(tidyverse) | |
| # read in data | |
| urlfile <- "https://raw.githubusercontent.com/Z-Unlocked/Unlocked_Challenge_1/main/temperature_change_data_11-29-2021.csv" | |
| mydata <-read_csv(url(urlfile)) | |
| # filter | |
| countries <- c("China", "Germany", "Japan", "United States of America") |
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
| #libs-------------- | |
| library(grid) | |
| library(tidyverse) | |
| library(ggdark) | |
| #funs-------------- | |
| irt <- function(a,b,c){ | |
| theta <- seq(-10,10, length = 500) | |
| exponent <- exp(a*(theta-b)) | |
| phat <- c + (1-c)*(exponent/(1 + exponent)) |
NewerOlder