Skip to content

Instantly share code, notes, and snippets.

View rudeboybert's full-sized avatar
💭
Keep it real

Albert Y. Kim rudeboybert

💭
Keep it real
View GitHub Profile
@rudeboybert
rudeboybert / SDS220_new_section_3_multiple_regression.Rmd
Last active March 30, 2022 12:55
New code for Section 3 on Multiple Regression
# Multiple linear regression
## Regression table
Instructions:
- Indicate which model you selected: parallel slopes or interaction.
- Fit your selected regression model and display the regression table in the code
block below
- Modify the template formula below from ModernDive 6.1.2 to match your model (this formula is written in the LaTeX typesetting language for printing mathematical formulas)
@rudeboybert
rudeboybert / README.txt
Created May 26, 2021 15:02
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=false&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
@rudeboybert
rudeboybert / CV_for_CART.R
Last active March 23, 2020 00:00
Using cross-validation to find optimal complexity parameter of a classification & regression tree
# Based on data from "House Prices: Advanced Regression Techniques" Kaggle Competition
# https://www.kaggle.com/c/house-prices-advanced-regression-techniques
# YouTube demo can be found here:
library(tidyverse)
library(rpart)
library(Metrics)
# Reload house prices data
train <- read_csv("https://rudeboybert.github.io/SDS293/static/train.csv")
@rudeboybert
rudeboybert / SQL_192.sql
Created December 3, 2019 23:21
SQL code
/* Show all databases in on scidb.smith.edu server. */
SHOW DATABASES;
/* Load the imdb database. */
USE imdb;
/* Show the names of all tables in imdb. */
SHOW TABLES;
/*
@rudeboybert
rudeboybert / joins.R
Created October 22, 2019 12:38
Different types of dplyr joins
library(dplyr)
# Create two example data frames:
dfA <- tibble(
ID = c(76, 79, 9),
age = c(21, 23, 24)
)
dfB <- tibble(
ID = c(79, 76, 11),
state = c("MA", "OR", "DE")
@rudeboybert
rudeboybert / import_calendar_into_R.R
Last active April 15, 2024 16:20
Code to import a Google Calendar, macOS Calendar, or Outlook calendar .ics file into R
library(ggplot2)
library(dplyr)
library(lubridate)
library(ical)
# For a screencast demo on creating a calendar and exporting it to .ics file format
# see this video: https://youtu.be/vLlR4lBWAoc
# Locate your .ics calendar file on your computer and change what's in quotation marks
calendar_data <- "192.ics" %>%
@rudeboybert
rudeboybert / moderndive_demo.R
Last active May 23, 2019 17:27
Code used in demo of moderndive talk
library(tidyverse)
# Install version 0.2.0.9000 or higher
# devtools::install_github("moderndive/moderndive")
library(moderndive)
# Chapter 8: "Virtual" sampling from a bowl of red/white balls
# Population:
bowl
# Sample from population:
bowl %>%
@rudeboybert
rudeboybert / sds-csc-293-LASSO.R
Last active April 22, 2019 18:14
SDS/CSC 293 LASSO example code
#------------------------------------------------------------------------------
# Lec21: 2019/04/22
#------------------------------------------------------------------------------
library(tidyverse)
library(glmnet)
library(broom)
library(modelr)
library(ISLR)
@rudeboybert
rudeboybert / sds-csc-293-CART.R
Last active April 14, 2019 16:33
SDS/CSC 293 CART Code
#------------------------------------------------------------------------------
# Lec14: 2019/03/25
#------------------------------------------------------------------------------
library(tidyverse)
# Pre-process iris dataset
iris <- iris %>%
# Convert to tibble data frame:
as_tibble() %>%
# Add identification variable to uniquely identify each row:
rownames_to_column(var="ID")
@rudeboybert
rudeboybert / moderndive_regression.R
Last active March 13, 2019 18:48
Demo of moderndive package functions for tidyverse & novice friendly linear regression
library(tidyverse)
library(moderndive)
# Convert to tibble:
mtcars <- mtcars %>%
rownames_to_column()
# Fit lm
mpg_model <- lm(mpg ~ hp, data = mtcars)