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
d = {} | |
for x in range(1, 10): | |
d["string{0}".format(x)] = "Hello" | |
d["string5"] | |
#'Hello' | |
d | |
#{'string1': 'Hello', | |
# 'string2': 'Hello', |
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
var_names <- paste0("p", 1:10) | |
values <- seq(100, 1000, by = 100) | |
for (i in seq_along(var_names)) assign(var_names[[i]], values[[i]]) | |
mget(var_names) | |
# $p1 | |
# [1] 100 | |
# | |
# $p2 |
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
unnest_dataframes <- function(x) { | |
y <- do.call(data.frame, x) | |
if ("data.frame" %in% sapply(y, class)) unnest_dataframes(y) | |
y | |
} |
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(httr) | |
library(jsonlite) | |
# API set up | |
api <- "https://api.airtable.com/v0/apphVdH23b9rXFd1p/" | |
api_key <- "keyL1Ja4L6pg3Uu9Q" # fake api_key | |
tables <- c("products", "brands", "stores") | |
# GET request |
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
inputModuleUI <- function(id){ | |
ns <- NS(id) | |
wellPanel(textInput(ns('text1'), "First text"), | |
textInput(ns('text2'), "Second text")) | |
} | |
inputModule <- function(input, output, session){ | |
vals <- reactiveValues() | |
observe({vals$text1 <- input$text1}) | |
observe({vals$text2 <- input$text2}) |
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
# UI ========================================================================== | |
returnUI = function(id) { | |
ns <- NS(id) | |
tagList( | |
textInput(ns("txt"), "Write something") | |
) | |
} |
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 * | |
from my_status | |
where date(enter_time) = date(now()); |
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(shiny) | |
for (file in list.files("modules", full.names = TRUE)) source(file) |
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
// create y in linear scale | |
var y = d3.scaleLinear().domain([15, 90]).range([250, 0]); | |
// create x in log scale | |
var x = d3.scaleLog().domain([250, 100000]).range([0, 600]); | |
// create r in radius scale | |
var r = d3.scaleSqrt().domain([52070, 1380000000]).range([10, 50]); | |
// append circle and attr to svg |
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(shiny) | |
library(DBI) | |
library(RPostgreSQL) | |
ui = basicPage( | |
) | |
server = function(input, output, session) { | |
con <- dbConnect(PostgreSQL(), | |
dbname = "myDB", |