Skip to content

Instantly share code, notes, and snippets.

View mine-cetinkaya-rundel's full-sized avatar

Mine Cetinkaya-Rundel mine-cetinkaya-rundel

View GitHub Profile
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / lm_glm.R
Last active July 16, 2016 06:22
Standard errors for lm and glm
# From https://stats.stackexchange.com/questions/224045/using-lm-for-2-sample-proportion-test
## prop.test gives pooled 2-sample proportion result
## glm w/ binomial family gives unpooled 2-sample proportion result
## lm and glm w/ gaussian family give unknown result
library(dplyr)
library(broom)
set.seed(12345)
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / app.R
Last active November 8, 2017 21:38
Shiny dynamic UI - observers & for loop
# An example based on http://shiny.rstudio.com/articles/dynamic-ui.html
library(shiny)
ui = basicPage(
fluidRow(
actionButton(inputId = "add_buttons", label = "Add 5 Buttons")
),
uiOutput("more_buttons") # this is where the dynamically added buttons will go
)
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / app.R
Last active March 21, 2023 15:16
Shiny dynamic UI - observers & lapply
# An example based on http://shiny.rstudio.com/articles/dynamic-ui.html
library(shiny)
ui = basicPage(
fluidRow(
actionButton(inputId = "add_buttons", label = "Add 5 Buttons")
),
uiOutput("more_buttons") # this is where the dynamically added buttons will go.
)
# Could this be an alternative solution for the following?
# https://github.com/jcheng5/rstudio2017-shiny-workshop/blob/master/apps/reactivity/cranlogs.solution.R
library(cranlogs)
library(dplyr)
library(lubridate)
library(ggplot2)
library(shiny)
# Define UI for specifying package and plotting cranlogs ------------
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / app.R
Created June 27, 2017 21:43
Shiny example: Diamonds Explorer
library(shiny)
library(ggplot2)
dataset <- diamonds
ui <- pageWithSidebar(
headerPanel("Diamonds Explorer"),
sidebarPanel(
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / app.R
Created August 9, 2017 21:47
Sample Shiny application demonstrating usage of Shiny Server Pro's authentication feature to customize the app according to the privileges of the logged-in user.
library(shiny)
library(ggplot2)
## Pre-app calculations
# Get the current day of the month
dom <- 25
# Define the target for salespeople in our organization.
salesTarget <- 15000
@mine-cetinkaya-rundel
mine-cetinkaya-rundel / model-parallel-lines.R
Created March 1, 2018 03:36
Plotting parallel regression lines
# Fit model with parallel lines (main effects only)
m_pr <- lm(log(price) ~ Surface + factor(artistliving), data = pp_Surf_lt_5000)
## Option 1
# Save regression coefficients in a tibble
m_pr_coefs <- m_pr %>%
tidy() %>%
select(term, estimate)
library(tidyverse)
# list col for age --------------------------------------------------
df_listcol <- tibble(
age = list(30, 40, 50, 55, "65+")
)
typeof(df_listcol$age)
#> [1] "list"
library(tidyverse)
library(rtweet)
library(glue)
tml <- get_timelines("CostcoRiceBag", n = 3200)
br <- tml %>%
filter(is.na(reply_to_screen_name)) %>%
slice(
which(str_detect(text, "IS IT JUST ME")):
# Load packages ----------------------------------------------------------------
library(shiny)
library(shinythemes)
library(ggplot2)
library(dplyr)
library(fiftystater)
library(tools)
library(mapproj)
library(fontawesome)