This file contains 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, module | |
from htmltools import TagList | |
app_ui = ui.page_fluid( | |
ui.row( | |
# add space from the left | |
ui.column(3), | |
# center with content | |
ui.column( | |
6, |
This file contains 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
import datetime | |
from typing import Dict, List, Optional, Tuple | |
import astropy.units as u | |
import matplotlib.dates as mpldates | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
import pytz | |
import suntime |
This file contains 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(lubridate) | |
df <- tibble( | |
dist1 = sort(rnorm(100, 5, 2)), | |
dist2 = sort(rnorm(100, 8, 3)), | |
dist4 = sort(rnorm(100, 15, 1)), | |
date = seq.Date(from = ymd("2022-01-01"), ymd("2022-04-10"), by = "day") | |
) |
This file contains 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) | |
survey <- tibble::tribble( | |
~id, ~q_1, ~q_2, ~q_3, | |
1L, "good", "bad", "neutral", | |
2L, "neutral", "good", "neutral", | |
3L, "bad", "neutral", "neutral", | |
4L, "neutral", "good", "neutral", | |
5L, "bad", "good", "neutral", | |
6L, "bad", "bad", "neutral" |
This file contains 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(janitor) | |
library(RcppRoll) | |
deaths <- read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv") | |
deaths <- deaths %>% | |
rename(province_state = `Province/State`, | |
country_region = `Country/Region`) %>% | |
pivot_longer(-c("province_state", "country_region", "Lat", "Long"), |
This file contains 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(RcppRoll) | |
library(lubridate) | |
library(broom) | |
covid <- read_csv("https://covid.ourworldindata.org/data/owid-covid-data.csv") %>% | |
filter(location != "World") | |
covid <- covid %>% | |
group_by(iso_code) %>% |
This file contains 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(rgeos) | |
library(RcppRoll) | |
library(rworldmap) | |
data <- read_csv("https://covid.ourworldindata.org/data/owid-covid-data.csv") %>% | |
filter(location != "World") | |
plot_df <- data %>% | |
group_by(iso_code) %>% |
This file contains 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
select_random <- function(tbl, n_records) { | |
tbl <- tbl %>% | |
dplyr::mutate(rand = random()) %>% | |
dplyr::compute() %>% | |
dplyr::arrange(.data$rand) %>% | |
dplyr::filter(dplyr::row_number(.data$rand) <= !!n_transactions) %>% | |
dplyr::select(-.data$rand) | |
} | |
tbl %>% |
This file contains 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
# | |
# This is a Shiny web application. You can run the application by clicking | |
# the 'Run App' button above. | |
# | |
# Find out more about building applications with Shiny here: | |
# | |
# http://shiny.rstudio.com/ | |
# | |
library(shiny) |
This file contains 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
call <- substitute(ifelse(v == 1, | |
"banana", | |
ifelse(v == 2, | |
2, | |
NA)) | |
) | |
parse_ifelse <- function(call) { | |
if (deparse(call[[3]][[1]]) == "ifelse") { | |
top_call <- deparse(call[[2]]) |
NewerOlder